![]() |
![]() ![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 550 Pomógł: 9 Dołączył: 29.05.2009 Skąd: Ostrów Wielkopolski Ostrzeżenie: (0%) ![]() ![]() |
Kod pliku sample_section2.tpl
CODE <table> {section name=id loop=$titles} <tr> <td>Tytuł: {$titles[id]}<br/> Cena: {$prices[id]}<br/> Autor: {$authors[id]}</td> </tr> {/section} Kod pliku sample_section2.php CODE <?php include ("Smarty.class.php"); $smarty = new Smarty(); $conn = pg_connect('dbname=xxxx user=xxxxx password=xxxxxx'); if(! is_resource($conn)) { throw new Exception('Nie można połączyć się z bazą danych.'); } $result = "SELECT title, price, author from books"; $rs = pg_query($conn, $result); while ($row = pg_fetch_assoc($rs)) { $titles[] = $row['title']; $prices[] = $row['price']; $authors[] = $row['author']; } $smarty->assign("titles",$titles); $smarty->assign("prices",$prices); $smarty->assign("authors",$authors); $smarty->display("sample_section2.tpl"); ?> Wynik jaki wyświetla mi: Tytuł: Pan Tadeusz Cena: Array Autor: 30 Tytuł: Lalka Cena: Array Autor: 50 Nie wiem dlaczego wyświetla przy cenie Array zamiast wartości z bazy? Ten post edytował cykcykacz 2.10.2009, 22:06:47 |
|
|
![]() ![]() |
![]() |
Aktualny czas: 25.08.2025 - 04:01 |