Hello!
I'm trying to make a category drop down menu made from a mysql database fieldname called 'category'. The table is called 'links'
I need to know how I can do the following:
1) Fetch data from the field named 'category' into a html drop-down menu.
2) Each category should only appear once in the drop-down.
3) The list should appear in alphabetic order.
here is what I got so far, but this doesn't work .... please help 😕
$sql = "SELECT * FROM links";
$result=mysql_query($sql, $connection);
$row = mysql_fetch_array($result);
if(mysql_num_rows($result)==0) {
echo "No data available";
}
else {
for($i=0;$i<mysql_num_rows($result);$i++) {
$row=mysql_fetch_assoc($result);
echo"<option>{$row['category']}</option>";
}
}