Trying to get the following code to work. Fairly simple, or should be 🙂 Just trying to populate a pulldown with values from a MySQL database table.
I have checked the SQL and that is working fine...not that difficult.
So, why is it when I run this the pull down just contains the word --Select-- and then a bunch of blanks?
$sqlOptions = "SELECT MEDIA_NAME, MEDIA_ID from MEDIA_TYPES";
$result = mysql_query($sqlOptions);
if (!$result) {
echo ("<P>Error performing query: " . mysql_error() . "</P>");
exit();
}
echo '<select name="Test">';
echo '<option value="">--Select--</option>';
while($opt = mysql_fetch_array($result))
{
echo '<option value="'.$opt['MEDIA_ID'].'">'.$opt['MEDIA_TYPE'].'</option>';
}
echo '</select>';