 | |  |
 |

Dave
Staff
/ Moderator

Nov 19, 2008, 2:31 PM
Post #3 of 4
(532 views)
Shortcut
|
|
Re: [ryan_dot] Populate a dropmenu with database values
[In reply to]
|
Can't Post
|
|
Hi Ryan, Try something like this:
<?php // get field options $tablename = 'widgets'; $fieldname = 'color'; $selectedValue = ''; $valuesAndLabels = getListOptions($tablename, $fieldname); $optionsHTML = getSelectOptions($selectedValue, array_keys($valuesAndLabels), array_values($valuesAndLabels)); ?> Widgets Colors: <select name="color"> <?php echo $optionsHTML ?> </select> Hope that helps! Dave Edis - Senior Developer interactivetools.com
|
|
|  |
 |

ryan_dot
User
Nov 19, 2008, 3:33 PM
Post #4 of 4
(530 views)
Shortcut
|
|
Re: [Dave] Populate a dropmenu with database values
[In reply to]
|
Can't Post
|
|
Hi Dave, i must try that the next time, it looks more efficient than what i ended up doing. I ended up creating a seperate table for the 'make' and linked it to the cars table and used this code to create a drop down menu for the search feature. <select name="make" class="dropdown" id="make" > <option value="">Any</option> <?php foreach ($makeRecords as $record): ?> <option value="<?php echo $record['make'] ?>"><?php echo $record['make'] ?></option> <?php endforeach; ?> </select> It works fine for me, and since there is now a table for 'make' it allows the site owner to add new makes to the database and it automatically updates the search menu. Thanks http://www.westendpropertysales.com http://www.eadiemcfarland.co.uk http://www.macneanrestaurant.com http://www.theclocktower.ie
|
|
|  |
|