<?php
if(!mysql_connect(*))
{
echo 'Connection failed. Please try again.';
exit;
}
else
{
$db_link = mysql_connect(*);
if (!mysql_select_db(*))
{
echo 'Error selecting database.';
exit;
}
}
$sql = "SELECT * FROM `Faculties` ORDER BY `Faculties` ";
$result = mysql_query($sql,$db_link);
$i = 0;
while ($row = mysql_fetch_assoc($result))
{
$faclist['$i'] = $row['Faculties'];
$i++;
}
?>
<td>Faculty:</td>
<td><select name="Faculty">
<?php
for ($c = 0; $c < $i; $c++)
{
echo '<option value="'.$faclist['$c'].'">'.$faclist['$c'].'</option>';
}
?>
</select>
</td>
I'm trying to input a list of faculties from my database, and store them in an array. That is successful (because I echoed it out onto the page), but when I try to make a dropdown menu for it the dropdown menu only shows a blank box with a long list of blank options, and nothing else. What's going on here?😕