Re: [SMARTY] Re: {section} with MySQL Data
| From: | schultzr at kattare dot com | Date: | Sat, 12 Apr 2003 22:42:45 +0000 |
| Subject: | Re: [SMARTY] Re: {section} with MySQL Data | ||
| References: | 1 2 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-9228@lists.php.net to get a copy of this message | ||
> As I mentioned, the correct code for you, would be
>
> $sql = mysql_query("SELECT id, title, text FROM news");
> while ($rs = mysql_fetch_array($sql) )
> {
> tmp[] = $rs;
> }
> $smarty->assign('newsdata', $tmp);
>
>
> thats all... try it!
A way to simplify this and not do the extra variable is the simple
append function in Smarty..
$sql = mysql_query("SELECT id, title, text from news");
while ($rs = mysql_fetch_array($sql) )
{
$smarty->append('newsdata',$rs);
}
easier then having to copy all your data into a new variable and then
assign'ing it. Unless you need to do some modification on the variables..