Hello, please tell me how to make auto filter between two search inputs? For exemple: while I choose a Zip code on list, then list of City name is filterd automatic according to this Zip code.
These are my code:
// Connect to db:
$dsn = "mysql:host=".DB_HOST.";dbname=".DB_NAME;
$db = new PDO($dsn, DB_USER, DB_PASSWORD, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
$sqlAll = "SELECT count(*) FROM `ab_staff` WHERE `anadd` IS NOT NULL";
$sth = $db->query($sqlAll);
$rowAll = $sth->fetch(PDO::FETCH_ASSOC);
$cntAll = number_format($rowAll['count(*)'], 0, ',', '.');
$title = "Trouver votre medecin/therapeute parmi nos $cntAll membres";
// Remove by Hoa 24/03/2015
// wp_enqueue_script('google-map-libs');
// wp_enqueue_script('mymap');
// Remove by Hoa 24/03/2015
$template = $events_page = get_pages(array('meta_key' => '_wp_page_template','meta_value' => 'recherche-medecin.php'));
$output = ($title_style == 'simple')?'<div class="col-title"><h2>'.$title.'</h2></div>':'<div class="gray-title"><span><i class="fa fa-search"></i></span><h3>'.$title.'</h3><h5>'.$tag_line.'</h5></div>';
$output .= '<div class="find-doctor">
<form class="doctor-search" method="post" action="'.get_permalink(sh_set(sh_set($template, 0), 'ID')).'">
<input type="hidden" name="page_id" value="'.sh_set(sh_set($template, 0), 'ID').'" />
<input class="span3" type="text" name="NomPrenom" placeholder="Nom/Prénom"/>
<select class="span3" name="Categorie">
<option value="Tous les spécialistes">Tous les spécialistes</option>';
// Categorie
$sqlRech = "SELECT distinct `ancat` from `ab_staff` ORDER BY `ancat`";
$sthRech = $db->query($sqlRech);
while ($rowRech = $sthRech->fetch(PDO::FETCH_ASSOC)) {
$cat = trim($rowRech['ancat']);
$selection = "";
if ( $cat === $Categorie ) {
$selection = " selected";
}
$output .='<option value="'.$cat.'" '.$selection.'>'.ucwords(strtolower($cat))."</option>";
}
$output .='</select>';
// Code Postal
$output .='<select class="span3" name="CodePostal"></option>';
$output .='<option value="" disabled selected style="display:none;">Code Postal</option>';
$sqlCP = "SELECT * FROM `HTC_zipcode` GROUP BY `zc_Cp` ORDER BY `zc_Cp`";
$sthCP = $db->query($sqlCP);
$outputVille = "";
while ($rowCP = $sthCP->fetch(PDO::FETCH_ASSOC)) {
$cp = $rowCP['zc_Cp'];
$selection = "";
if ( $cp === trim($CodePostal) ) {
$selection = " selected";
}
$output .='<option value="'.$cp.'" '.$selection.'>'.$cp.'</option>';
}
$output .='</select>';
// Ville
$output .= '<select class="span3" name="Ville"><option value=""></option>';
$output .='<option value="" disabled selected style="display:none;">Ville</option>';
$sqlCP = "SELECT * FROM `HTC_zipcode` GROUP BY `zc_Ville` ORDER BY `zc_Ville`";
$sthCP = $db->query($sqlCP);
while ($rowCP = $sthCP->fetch(PDO::FETCH_ASSOC)) {
$selection = "";
$ville = $rowCP['zc_Ville'];
$selection = $selectionVille = "";
if ( $ville === $Ville ) {
$selection = " selected";
}
$output .= '<option value="'.$ville.'" '.$selection.'>'.$ville.'</option>';
}
$output .='</select>
<input type="hidden" name="Recherche" value=1>
<input type="submit" name="Recherche1" keyword="name" value=""/>
</form>
</div>';
// print_r($atts);
return $output ;
}
Thanks!