Dear all,
I am having trouble displaying data from a MySQL database into a simple select (combo style) box. I know the data is retrieved from the database because the following works ok!
// Works
<?php
$dbh=@mysql_connect("localhost:3306", "pcm", "infinity");
@mysql_select_db("pcm", $dbh);
$query="SELECT * FROM content";
$res=@($query, $dbh);
while($row=@mysql_fetch_array($res)) {
print $row[name]."<br>";
}
?>
However, I just cant get this to work! I been making many small tweaks to the code for hours, but just cant get it to display in the select box. Does anyone have any ideas why this might be?
This doesnt work!
<?php
$dbh=@mysql_connect("localhost:3306", "pcm", "infinity");
@mysql_select_db("pcm", $dbh);
$query="SELECT * FROM content";
$res=@($query, $dbh);
?>
<select name="software">
<?php
while($row=mysql_fetch_array($res))
{
echo "<option value= ";
echo $row[name];
echo "</option>";
}
?>
</select>
Any help or suggestions would be much appreciated!
Thanks in advance, Regards
- Pete