I am currently using this script (posted by another member) to create a dropdown list which is created from my MySQLdatabase.
//Query to get info
$trow = mysql_query("SELECT * FROM table");
if (!$trow) {
echo 'Could not run query: '.$trow."\n". mysql_error();
exit;
}
//Dropdown list
PRINT "<p><font size='2' face='Tahoma'>Please Select Category.</font><br>
<select name='search' size='1' style='background: white' style='border_width: 1pt' style='border-color: black'>";
//looping over db records
while ($row = mysql_fetch_row($trow)) {
print "<option>$row[2]</option>";
}
I am pulling business categories to fill in the dropdown list and lots of businesses share the same category type. When this script is run, it lists the entire category column from the database in the dropdown which includes multiple repeats and in order in which they were entered into the database.
Is there a way to:
1) Remove repeats from the dropdown list (even thought they are in the MySQL database?
2) Sort the dropdown alphabetically?
Thanks in advance.