après l'ajout de votre code html
<div class="showsearch"></div>
code js
$(document).ready(function(){
$('#drop2').on('change',function(){
var fname = $(this).val();
// rename your file which include $fname with get_search_data.php
if(fname !== ""){
$.post('get_search_data.php',{fname: fname},function(data){
$('.showsearch').html(data);
});
}
});
});
- après ce code, il devrait afficher le $row['fname'] pour afficher la div recherche
- vous devez inclure("connection.php"); dans get_search_data.php
get_search_data.php
<?php
include("connection.php");
if(isset($_POST['fname'])){
$fname = mysqli_real_escape_string($con, $_POST['fname']);
}
$sql1 = 'SELECT * FROM office WHERE fname LIKE "%'.$fname.'%"';
$result = mysqli_query($con, $sql1);
if (mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_assoc($result)) {
echo $row["fname"]; // this data should appear in showsearch div
}
} else {
echo "0 results";
}
mysqli_close($con);
?>