Hi Slindt,
I would add one table for each drop-down, IF you will have a limited number of drop-downs, OR if these dropdown-tables are also used as a lookup for your main tables.
I have used a similar setup for a management module, where users are allowed to add options to the drop-down menus. I wrote two functions on top of that: One functions get_table, which will get all values from a table, sorted by the first colum.
The second will use this data and build the core of a dropdown. (I cannot find the get_table right now, but this coul dbe very easy, see example below; the dropdown is below. Hope it helps)
Get table like this:
function get_table($table)
{
$query = "select * from $table ";
$result = mysql_query($query);
$array = array()
if($result)
{
while($row = mysql_fetch_array($result))
{
$array[] = $row;
}
return $array;
}
else
{
return false;
}
}
// generic function to create a dropdown body from an array
// $array: input data, each array element represents information about one dropdown enrtry, in an sub-array
// $selected_id: Identifier of the selected drop-down element
// $value_label: The name of the array-element that holds the value for the dropdown
// $name_label: The name of the array-element that holds the name for the dropdown element
function create_dropdown($array, $selected_id, $value_label, $name_label)
{
$dropdown = "";
foreach($array as $key=>$value)
{
$selected = "";
if($value[$value_label] == $selected_id)
{
$selected = "selected";
}
$dropdown .="<option $selected value=\"".$value[$value_label]."\">".$value[$name_label]."</option>
";
}
return $dropdown;
}