0

Hi, I'm trying to create a drop down menu with dynamically populated options.
So, within a typical HTML form I have:

$conn = mysql_connect ("localhost", "xxxx", "xxxx");
mysql_select_db ("wkho_TTX", $conn);

$query = "SELECT * FROM venues"; 
				$result = mysql_query($query) or die(mysql_error());
				$num=mysql_numrows($result);	 
				$i=0;
				while ($i < $num) {
                	$option = mysql_result($result,$i,'vname');
                	echo '<option value='.'$2option'.'>.$1option.</option>';
					$i++;
				}

I think the problem is with the echo line, but can't format it to show the value of option.
Can anyone help please?

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by lyrico
0

I format your code. try this.

$conn = mysql_connect ("localhost", "xxxx", "xxxx");
mysql_select_db ("wkho_TTX", $conn);

$query = "SELECT * FROM venues";
$result = mysql_query($query) or die(mysql_error());
$num=mysql_numrows($result); //change this to $num=mysql_num_rows($result);
$i=0;
while ($i < $num)
{
$option = mysql_result($result,$i,'vname'); // i dont know waht is vname?
echo "<option value='$2option'>".$1option."</option>"; // notice the (") and (')
$i++;
}

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.