I have a form with a dropdown field which I would like to populate with a list of bands that exist in my 'bands' database. I have tried several pieces of code, but the dropdown list is always empty. I know that the DB connection is fine because I am calling the connection in several parts of my application. Here is my attempt at the code:
<?php
$select_query= "Select bandname from bands";
$select_query_run = mysql_query($select_query);
echo "<select name='bands'>";
while ($select_query_array= mysql_fetch_array($select_query_run) )
{
echo "<option value='' >".htmlspecialchars($select_query_array["bandname"])."</option>";
}
echo "</select>";
?>