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?

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++;
}

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.