This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
$( document ).ready( function(){ | |
$( "#countrySelect" ).autopopulatedselect( "#townSelect" ); | |
}); | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Create a PDO object for database | |
$server = 'localhost'; | |
$db_name = 'select_autopopulate_tutorial'; | |
$username = 'root'; | |
$password = ''; | |
try{ | |
$sqldata = new PDO('mysql:host='.$server.';dbname='.$db_name,$username,$password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION) ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE countries ( | |
country_id INT AUTO_INCREMENT PRIMARY KEY, | |
country_name VARCHAR(255), | |
country_code VARCHAR(3) | |
); | |
CREATE TABLE towns ( | |
town_id INT AUTO_INCREMENT PRIMARY KEY, | |
town_name VARCHAR(255), | |
country_code VARCHAR(3) /* The country of the current town */ |