I want a select/ dropdown menu with its options coming from the database using mysql select query.
PROBLEM: the dropdown menu displays the correct number of items inside the database but is not showing those items, just a blank option. e.g: there are four items in the database the dropdown menu has four blank options in it.
<label for="category">Category</label><select name=cat><option value=""> --Select Category-- </option>
<?php $sql= mysqli_query($con, "SELECT category FROM taxonomy");
while($result = mysqli_fetch_array($sql)){
echo "<OPTION VALUE='".$row[0]."'>".$row[0]."</OPTION>";
}
?>
</select>
Can someone please tell me what's wrong?
Change
to
in $result add this
and
http://php.net/manual/en/mysqli-result.fetch-array.php