I would like to create a simple select drop down, to be populated by a table in my MYSQL database.
Here is my code:
$q = 'SELECT * FROM Shipmethods';
$result = mysqli_query($connection, $q);
echo '<select name="shipmethod">';
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC));
{
echo '<option value="' . $row['shipmethodid'] . '">' . $row['shipmethoddesc'] . '</option>';
}
echo '</select>';
mysqli_free_result($result); // free up the results
}
There is no connection error, no typos in table name or column names. The HTML output shows that a select option exists, but it is empty. I would like to use mysqli for this.
There seem to be countless topics already on this subject, but as far as I can see, my code matches the correct answers of those already answered questions.
Thanks in advance.
Remove
;from this line, rest code seems fine to me, let me know if it works or not —To