View Full Version : Generating drop don choices in a from based on SQL entries
lightnb
05-21-2006, 10:51 PM
I want to have a form with a drop down box, where all of the choices it gives are from a field in a table in a database.
For example, if the first 5 entries of my database are:
Make Model Year
Dodge Neon 97
Dodge Neon 98
Dodge Neon 99
Ford F 150 03
Ford F 250 04
I want a Form to appear with a "make" drop down box that gives the choices:
Dodge
Ford
Is that possible?
Thanks,
Nick
Sure, you could probably do something like:
<select name="make">
<?php
$query = mysql_query("SELECT DISTINCT Make FROM your_table");
$options = '';
while ($row = mysql_fetch_array($query))
{
$options .= '<option value="'.stripslashes($row['Make']).'">'.stripslashes($row['Make']).'</option>';
}
echo $options;
?>
</select>
lightnb
05-23-2006, 12:36 AM
cool. Thank you.
Dax IX
01-03-2009, 07:38 AM
Is there an updated version of how to do this? I could have sworn I saw something about how to construct forms in newer versions, but I can't seem to find it now.
Also, is there a list of all functions, etc for vBulletin anywhere?
Thanks! :)
Dismounted
01-03-2009, 09:24 AM
<a href="http://members.vbulletin.com/api/" target="_blank">vBulletin API</a>
Dax IX
01-03-2009, 09:52 AM
Thank you. :) After more searches I came across that PDF. :o
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.