Smarty PHP Question
| From: | Jarrod Lash | Date: | Sat, 17 Aug 2002 20:53:25 +0000 |
| Subject: | Smarty PHP Question | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-5734@lists.php.net to get a copy of this message | ||
I am trying to create a generated menu from a database to a smarty template
and I am having problems. Can somebody shed some light for me?
============================================================================
===========
I have this in my php file
$db->setFetchMode(DB_FETCHMODE_ASSOC);
$result = $db->query('select * from menu where parent = NULL');
while ($row = $result->fetchRow()) {
$menuid = $row['menuid'];
$display_name = $row['display_name'];
$link = $row['link'];
$parent = $row['parent'];
$location = $row['location'];
}
$smarty->assign("display_name",?);
$smarty->assign("link",?);
============================================================================
===========
and this in my template file
<table border="5" cellpadding="0" cellspacing="0"
style="border-collapse:
collapse" width="100%" id="AutoNumber1" bgcolor=gray>
<tr>
<td width="100%" bgcolor=yellow><CENTER><B>MAIN
MENU</B></CENTER></td>
</tr>
<tr>
<td width="100%">
{section name=menu loop=$menuid}
<a href="{$link[menu]}">{$display_name[menu]}</a><br>
{/section}
</td>
</tr>
</table>
============================================================================
===========
What I cant figure out is how to move the data from the database to the
template. I think I should have some kind of array variable where the ? is
in the php file. Also should menuid in the smarty loop be the number of
rows I returned from the database?
Thanks,
Jarrod Lash