Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Pętla smarty
Wieczny
post
Post #1





Grupa: Zarejestrowani
Postów: 191
Pomógł: 1
Dołączył: 21.03.2007

Ostrzeżenie: (60%)
XXX--


Witam czy poprawnie napisałem pętle w smarty ?

  1. <?php
  2. {foreach from=$news item=item}
  3.  
  4. {$item}
  5.  
  6. {/foreach}
  7. ?>


Problem jest taki że pokazuje ostatni rekord w bazie zamiast wszystkie (IMG:http://forum.php.pl/style_emoticons/default/blinksmiley.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Spykaj
post
Post #2





Grupa: Zarejestrowani
Postów: 104
Pomógł: 3
Dołączył: 30.05.2008
Skąd: Białystok

Ostrzeżenie: (0%)
-----


Spróbuj tak:

  1. <?php
  2. require_once ('_mysql.php');
  3. require_once ('./lib/Smarty/Smarty.class.php');
  4. require_once ('_function.php');
  5.  
  6. $smarty = new Smarty;
  7.  
  8. $news = mysql_query("SELECT id, title, news, date, user, level
  9. FROM wpp_news");
  10. $res = array();
  11. while($res[] = mysql_fetch_row($news));
  12.  
  13. $smarty -> assign('news', $res);
  14. $smarty -> display('news.tpl');
  15. ?>


Ten post edytował Spykaj 29.06.2008, 14:00:34
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: 17.10.2025 - 06:17