Re: Dropdown menus from DB query
| From: | pete M | Date: | Fri, 18 Jun 2004 09:54:53 +0000 |
| Subject: | Re: Dropdown menus from DB query | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-34833@lists.php.net to get a copy of this message | ||
this is where smarty templating is so cool
using PEAR db
php code
$sql = 'select id, name from names order by name asc';
$smarty->assign('names',$db->getAssoc($sql));
template
<select name="name">
{html_options options=$names}
</select>
Cole Ashcraft wrote:
How would you create a drop down menu from a database query? I have figured how to do it with one field, but how could it be done with a system where the value is different than the displayed value (ie. numerical code as the value, name displayed)? Thanks, Cole