Skip to content

Instantly share code, notes, and snippets.

@tonyvich
tonyvich / index.php
Last active March 22, 2020 08:08
Plugin init
<script>
$( document ).ready( function(){
$( "#countrySelect" ).autopopulatedselect( "#townSelect" );
});
</script>
@tonyvich
tonyvich / index.php
Created March 22, 2020 08:00
Example of using select autopopulate no Ajax In php
<?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) );
}
@tonyvich
tonyvich / database_definition.sql
Created March 22, 2020 07:56
Database Definition Select Autopopulate php tutorial
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 */