Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php][tpl] pętla while
krystian1991x
post
Post #1





Grupa: Zarejestrowani
Postów: 114
Pomógł: 0
Dołączył: 7.08.2010

Ostrzeżenie: (10%)
X----


Coś mi pętla nie działa chodź w innym skrypcie zrobiona tak samo działa perfekto ...

kod tpl

  1.  
  2.  
  3. {foreach from=$result key=myId item=news name=news}
  4. <div style="margin-top: 25px;margin-left: 78px; width: 483px; height: 280px; background-image: url('templates/images/bgnews.jpg');">
  5. <table style="font-family: Arial;font-size: 18px; color: #e1d2d2; margin-left: 11px; margin-top: 10px;width: 465px; height: 51px; background-repeat: repeat-x; background-image: url('templates/images/titlenews.jpg');">
  6. <tr>
  7. <td style="padding-left: 8px;padding-bottom: 10px;">{$news.title}</td>
  8. </tr>
  9. <table style="fotn-size: 12px;color: #acacac;">
  10. <tr>
  11. <td style="padding-left: 25px; padding-top: 10px;"><img src="templates/images/{$news.img}.jpg" align='left' />{$news.text}</td>
  12. </tr>
  13. </div>
  14. {/foreach}

kod php
  1. <?php
  2.  
  3. require('cfg.php');
  4. require_once('login.php');
  5. $smarty = new Smarty;
  6. $result = mysql_query("SELECT id, title, author, text, img, date FROM news ORDER BY id ASC")
  7. or die("Niepoprawne zapytanie MySQL");
  8.  
  9.  
  10. while ($news = mysql_fetch_array($result))
  11. {
  12. $tablica[] = $news;
  13.  
  14. }
  15.  
  16. $smarty->assign('result',$tablica);
  17.  
  18.  
  19. $smarty->display('news.tpl');
  20.  
  21. ?>


Bądź tu mądry i pisz wiersze dodam że plik jest wczytywany do pliku index

co takie trudne ? hmm chyba muszę dać w inny dział w takim razie ?

CO TU JEST NIE TAK ?!

widzę że samy profesjonaliści zasiadają na tym forum (IMG:style_emoticons/default/aaevil.gif)

blabalbalba (IMG:style_emoticons/default/sciana.gif) (IMG:style_emoticons/default/sciana.gif) (IMG:style_emoticons/default/sciana.gif) (IMG:style_emoticons/default/sciana.gif)
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 16:13