Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with code to supply list from database

Status
Not open for further replies.

Evil8

MIS
Mar 3, 2006
313
US
I'm trying to supply a list/drop down that pulls cities from a mySQL database. I'm getting an error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in ... line 73

my code:
Code:
<?php 
        ...

	mysql_connect($host,$username,$password);
	@mysql_select_db($database) or die("Unable to select database");
		
	$query = "SELECT venue.venueid, venue.city FROM venue";
 	$result = mysql_query($sql);
	
	$options="";

	while ($row = mysql_fetch_array($result)) {
	
		$id = $row["venueid"];
		$city = $row["city"];
		$options.="<OPTION VALUE=\"$id\">".$city.'</OPTION>';
	}
?>

<form name="pickcity" method="post" action="">
        Find a meeting in my city: 
        <SELECT NAME=city>
		<OPTION VALUE = 0>Choose
		<?=$options?>
        </select>
		
</form>

The list will be used to return data based on which city is picked, but I have to get the first part working first.

Thank you!
 
Never mind. I fixed it.

instead of
Code:
$result = mysql_query($sql);
that line should be
Code:
$result = mysql_query($query);

Now on to getting results from the list box...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top