Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [SMARTY] Pobieranie danych z bazy
maxmer
post
Post #1





Grupa: Zarejestrowani
Postów: 4
Pomógł: 0
Dołączył: 25.03.2007

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


Nie wiem co jest nie tak pobieram dane z bazy ale treść itd. są w jednej linijce jak zrobić by każdy news był w nowej linii?

index.php
  1. <?
  2. require('db_connect.php');
  3. require('./smart/Smarty.class.php');
  4.  
  5.  $tpl = new Smarty;
  6. $tpl -> template_dir = './templates/';
  7. $tpl -> compile_dir = './templates_c/';
  8.  
  9.  
  10. $tablica = array();  
  11. $Query='SELECT * FROM news'; 
  12. $result = mysql_query($Query) or die(mysql_error());
  13. while($a = mysql_fetch_array($result)) 
  14. {
  15.  
  16. $tablica[] = $a;
  17.  
  18. }
  19. $tpl -> assign('news', $tablica);  
  20. $tpl -> display('lcms/index.tpl');
  21. ?>



index.tpl

  1. <table width="100%">
  2. <tr>
  3. <td>{section name=a loop=$news} {$news[a].name} {/section}</td>
  4. </tr>
  5. <tr>
  6. <td>{section name=a loop=$news} {$news[a].txt} {/section}</td>
  7. </tr>
  8. <tr>
  9. <td>{section name=a loop=$news} {$news[a].data} {/section}</td>
  10. <td>{section name=a loop=$news} {$news[a].autor} {/section}</td>
  11. </tr>
Go to the top of the page
+Quote Post

Posty w temacie
- maxmer   [SMARTY] Pobieranie danych z bazy   11.05.2007, 20:40:58
- - rojmarek   Cytat(maxmer @ 11.05.2007, 19:40:58 )...   11.05.2007, 22:41:21


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 - 08:15