I am populating an array from a MySQL Database, the problem is I get 9 blank fields in my dropdown box that I am trying to populate it with. What did I do wrong?
php code:
while($row = mysql_fetch_assoc($results))
{
$options[] = array(
Name => $row['Name'],
Value => $row['Value'],
ID => $row['CID']
);
}
dropdown box:
for ($i = 0; $i < 9; $i++)
{
print '<option id="'.$options[$i]["ID"].'" value="'.$options[$i]["Value"].'">'
.$options[$i]["Name"].
'</option>'."\n";
}
Your quotes are backwards in your array
Also, using an associative array in double quotes requires you to do this:
If you don’t do it this way, it (should) result in a parse error.
You might notice that this also works
But this is not good practice because if there is a constant through a define() named index, all of your statements will use your constant’s definition instead of the string you intended.