I am trying to populate a drop-down list via PHP embedded in HTML.
Here is what I have so far:
<select name="ChapterList" id="ChapterList" style="width:120px;">
<?php
$username = "xxxxxxxxxxx";
$password = "xxxxxxxxx";
$database = "xxxxxxxxxxxxxx";
$host = "xxxxxxxx.mydomainwebhost.com";
@mysql_connect($host, $username, $password) or die("Unable to connect to database");
@mysql_select_db($database) or die("Unable to select database");
$query = "SELECT * FROM Chapters ORDER BY Id";
$ListOptions = mysql_query($query);
while($row = mysql_fetch_array($ListOptions))
{
echo "<option value='".$row['Id']."'>".$row['ChapterName']."</option>"
}
?>
</select>
I know I am recieving the expected results because if I echo $row['ChapterName']; , the current values I have in the database are listed in the proper order, so why is it when I echo "<option value='".$row['Id']."'>".$row['ChapterName']."</option>" my list receives nothing at all?
Ok… so I solved my own question in a way.
What I discovered was that my php was being commented out via
<--!-->. I merely changed the file extension to.phpas opposed to.html. The drop-down list worked immediately and was populated with the proper values.But this raises another question… how can I get inline PHP to work? My site is hosted with MyDomain. Is there a setting I am missing somewhere?