Note that there are some explanatory texts on larger screens.

plurals
  1. POhow can i get countries states list from states table ,when i select country from countries table using multiple selection dropdown?
    primarykey
    data
    text
    <p>how to get countries states list from states table when i select country from countries table using multiple selection dropdown list ? here is my coding.</p> <h2>mysql tables</h2> <pre><code>CREATE TABLE `countries` ( `countryID` varchar(3) NOT NULL default '', `countryName` varchar(52) NOT NULL default '', `localName` varchar(45) NOT NULL, `webCode` varchar(2) NOT NULL, `region` varchar(26) NOT NULL, `continent` enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL, `latitude` double NOT NULL default '0', `longitude` double NOT NULL default '0', `surfaceArea` float(10,2) NOT NULL default '0.00', `population` int(11) NOT NULL default '0', PRIMARY KEY (`countryID`), UNIQUE KEY `webCode` (`webCode`), UNIQUE KEY `countryName` (`countryName`), KEY `region` (`region`), KEY `continent` (`continent`), KEY `surfaceArea` (`surfaceArea`), KEY `population` (`population`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; </code></pre> <h1>Structure for the <code>states</code> table :</h1> <pre><code>CREATE TABLE `states` ( `stateID` smallint(5) unsigned NOT NULL auto_increment, `stateName` varchar(50) NOT NULL default '', `countryID` varchar(3) NOT NULL, `latitude` double NOT NULL default '0', `longitude` double NOT NULL default '0', PRIMARY KEY (`stateID`), KEY `stateName` (`stateName`), KEY `countryID` (`countryID`), KEY `unq` (`countryID`,`stateName`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; </code></pre> <h1>Data for the <code>countries</code> table (LIMIT 0,500)</h1> <pre><code>INSERT INTO `countries` (`countryID`, `countryName`, `localName`, `webCode`, `region`, `continent`, `latitude`, `longitude`, `surfaceArea`, `population`) VALUES ('BRA','Brazil','Brasil','BR','South America','South America',-10,-55,8547403.00,170115000), ('CHN','China','Zhongquo','CN','Eastern Asia','Asia',35,105,9572900.00,1277558000), ('FRA','France','France','FR','Western Europe','Europe',47,2,551500.00,59225700), ('IND','India','Bharat/India','IN','Southern and Central Asia','Asia',28.47,77.03,3287263.00,1013662000), ('USA','USA','United States','US','North America','North America',38,-97,9363520.00,278357000); COMMIT; </code></pre> <h1>Data for the <code>states</code> table (LIMIT 0,500)</h1> <pre><code>INSERT INTO `states` (`stateID`, `stateName`, `countryID`, `latitude`, `longitude`) VALUES (5,'California','USA',37.42,-122.06), (6,'Beijing','CHN',39.93,116.39), (9,'Iowa','USA',43.03,-96.09), (10,'New York','USA',40.76,-73.97), (12,'... ....','CHN',32.06,118.78); COMMIT; </code></pre> <h2>Countries dropdown</h2> <p></p> <pre><code>&lt;? $Type_sql="SELECT countryName FROM countries ORDER by countryName ASC"; $Type_result=mysql_query($Type_sql); while($Type_rows=mysql_fetch_array($Type_result)){ echo "&lt;option value='"; echo $Type_rows['countryName']; echo "'&gt;"; echo $Type_rows['countryName']; echo "&lt;/option&gt;"; } ?&gt; &lt;/select&gt; </code></pre> <h2>states dropdown</h2> <p></p> <pre><code>&lt;? $Type_sql="SELECT stateName FROM countries c, states s where c.countryID = s.countryID ORDER by stateName ASC"; $Type_result=mysql_query($Type_sql); while($Type_rows=mysql_fetch_array($Type_result)){ echo "&lt;option value='"; echo $Type_rows['stateName']; echo "'&gt;"; echo $Type_rows['stateName']; echo "&lt;/option&gt;"; } ?&gt; &lt;/select&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload