Re: section problem
| From: | Pete Morganic | Date: | Fri, 20 Jun 2003 16:37:08 +0000 |
| Subject: | Re: section problem | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-9747@lists.php.net to get a copy of this message | ||
These links might help
http://www.codeforsoup.com/edu/smarty.php
http://www.zend.com/zend/tut/tutorial-cezar.php?print=1
I use PEAR db - this is an abstraction layer for databases and the code gets ridicouldy easy
eg
$sql = 'select id, name, address from customers';
$smarty->assign_by_ref('rows',$db->getAll($sql));
hope it helps
pete
Esteban Fernandez wrote:
Hi there
I think this is a very basic question, but i'm newbie in Smarty, i hope
someone can help me. I try list all the content in a table called "news",
this display news of cource in the main page, well that's the main idea..
I have this PHP code:
[php]
$link = db_connect();
$result = mysql_query("SELECT * FROM news WHERE news_status LIKE 1 ORDER BY
news_date ASC");
while ($row = mysql_fetch_array($result)) {
$smarty->assign("row", $row);
}
$smarty->display("news.tpl");
[/php]
And my Smarty code
{secion name=news loop=$row[0]}
Title: {$row[1]}<br>
Content: $row[2]}<br>
{/section}
The problem: i have 5 != news in the table, but the Smarty list the just the
last new in 5 times!, how can i resolv this problem ?. Comments and suggest
are welcome.
Thanks in advanced.
EF.