how to populate combobox with data from mysql

I need to display data from mysql table into a combobox. So far have not got the desired results.
The statements that i echo are not being displayed on the webpage. I know that php has been configured correctly as i have run other scripts successfully. please advise

This is the code:
[php]<form id=“form” action = “tableorders.php” method=“post”

Table No:

Select an option
	<?		echo "This is a test.";
			@ $db = mysql_pconnect("localhost","root","administrator");
if (!$db)
{
	echo "Error: Could not connect to database. Please try again later.";
	exit;		
}
mysql_select_db("orders");
$query = "select * from tables ";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);

for($i=0; $i < $num_results; $i++)
{
	$row = mysql_fetch_array($result);
            echo htmlspecialchars( stripslashes($row["tableNo"]));
	echo "<option value="row["tableno"]" >$row["tableno"]</option>"; .......................Please advise
	echo "</select>";
	echo "</form>";
	 
	echo "</p>";
}
		?>
		
		</td></tr>[/php]

The row above echo “<option value=“row[“tableno”]” >$row[“tableno”]”; displays an eror stating,
Parse error: syntax error, unexpected T_STRING, expecting ‘,’ or ‘;’
Please advise.

I have managed to display tableno 1 in the dropdown list. The table nos between 2 and 20 get displayed on the webpage instead of the dropdown list. What could be the cause of this. Please advise.

echo “”; needed to be put outside the loop. This resolved the issue.

Sponsor our Newsletter | Privacy Policy | Terms of Service