List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:March 8 2003 5:59pm
Subject:Re: simple query
View as plain text  
At 17:21 +0000 3/8/03, Andrew wrote:
>come on guys I nedsome help here! MySQL Rocks
>
>I have a set of drop downs I want to determine the dropdown menu by query?
>
>I have:
><?
>require("connection.php");
>
>mysql_connect("$DBHost", "$DBUser", "$DBPass") or
>         die("could not connect");
>     mysql_select_db("$DBName");
>
>echo "<select name=\"CountyID\" size=\"1\" class='menuForm'>";
>
>$result=mysql_query("SELECT County, CountyID FROM county ORDER BY County");
>while ($row = mysql_fetch_array($result))
>     {
>         $county_id=$row['CountyID'];
>		$county=$row['County'];
>echo "<option value=\"$county_id\"> $county </option>";
>}
>echo "</select>";
>?>
>
>which takes us to:
>
><?
>
>echo "<select name=\"CityID\" size=\"1\" class='menuForm'>";
>
>$result=mysql_query("SELECT City, CityID FROM city ORDER BY City");
>while ($row = mysql_fetch_array($result))
>     {
>         $city_id=$row['CityID'];
>		$city=$row['City'];
>echo "<option value=\"$city_id\"> $city </option>";
>}
>echo "</select>";
>?>
><br />
>
><? 
>
>but I want the city selction to be only where it is associated with 
>the county?

Which means what, exactly?  You want only those cities to be displayed
that are located in the currently-selected county?  If so, that's not
a MySQL question at all.  It's a question of client-side programming, for
example, using JavaScript.

Or do you mean something else?

>
>
>
>#
># Table structure for table `city`
>#
>
>CREATE TABLE city (
>   CountyID int(10) unsigned NOT NULL default '0',
>   City varchar(100) NOT NULL default '',
>   CityID bigint(20) NOT NULL auto_increment,
>   PRIMARY KEY  (CityID),
>   KEY CountyID (CountyID)
>);
>
>Andrew

Thread
simple queryAndrew8 Mar
  • Re: simple queryPaul DuBois8 Mar