if your only aim to display a dopdown list,
i share with you a little function which can make it:
<?php
function make_roll($table,$var,$field_)
{
$fields=explode(",",$field_); /* Lets explode the third parameter using "," as a separator*/
print '<select name="'.$var.'" size="1" id="'.$var.'">
<option value="">All</option>';
/*Lets create the mysql query, fo select the fields from the table using GROUP to make
the second field as unique*/
$sql="SELECT $field_ FROM $table GROUP BY {$fields[1]} ORDER BY {$fields[1]} ASC";
$r=mysql_query($sql);
while ($res = mysql_fetch_assoc($r))
{
/* its useful to use htmlspecialchars where you print the list's value*/
echo "<option value=\"" .$res[$fields[0]] ."\">" . htmlspecialchars($res[$fields[1]]) ."</option>\r";
}
print '</select>';
}
?>
first parameter is the table name of your database, second will be the variable name of your list.
The third parameter contains two field name separated with a , sign :
-The first of this is the id usually, and the second is the value.
<?php
//an example
make_roll("courses" , "cid" , "course_id,course_name");
?>
of course you can use this function to make another dropdown's:
<?php
//an example
make_roll("persons" , "pid" , "person_id,person_name");
make_roll("cars_type" , "cars_id" , "car_id,car_type");
ect...
?>