So, I’m trying to create a drop-down, dynamic select box.
Essentially, MySQL iterates through the rows, printing ‘vname’ from each line.
This works as a standalone code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<select>
<?php
$conn = mysql_connect ("xxxx", "xxxx", "xxxx");
mysql_select_db ("database", $conn);
$query = "SELECT * FROM venues";
$result = mysql_query($query) or die(mysql_error());
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
echo"<option value=".mysql_result($result,$i,'vname').">".mysql_result($result,$i,'vname')."</option></br>";
$i++;
}
?>
</select>
</body>
</html>
…which is cool.
This seems to break the page though:
<form id="new_session" action="prcs_create_session.php" method="post">
<table>
<tr>
<td>
Location
</td>
<td>
<select name="location" id="location">
<?php
/*
$query = "SELECT * FROM venues";
$result = mysql_query($query) or die(mysql_error());
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
echo"<option value=".mysql_result($result,$i,'vname').">".mysql_result($result,$i,'vname')."</option></br>";
$i++;
}
*/
include(qtestinc.php);
?>
</select>
</td>
</tr>
</table>
<input type="submit" value="Create session" />
<input type="reset" value="Start again" />
</form>
…which won’t let the select list print anything. What is happening?