<html>
<head>
<title> Halaman Pencarian </title>
<script src="jquery-1.4.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
//apabila terjadi event onchange terhadap object <select id=comboKategori>
$("#comboKategori").change(function(){
var prop = $("#comboKategori").val();
$.ajax({
url: "ajax.php",
data: "op=generatecomboMerk&prop="+prop,
cache: false,
success: function(msg){
//jika data sukses diambil dari server kita tampilkan
//di <select id=comboMerk>
$("#comboMerk").html(msg);
}
});
});
});
</script>
</head>
<body>
<table width='700' align="left" border='1'>
<tr>
<td width='200'> Produk Terbaru
<p> </p>
<p> </p>
</td>
<td width='500'>
<form name="formcari" method="post" action="formsearching.php">
<table width="330" border="0" align="center" cellpadding="0">
<tr bgcolor="orange">
<td height="25" colspan="3">
<strong> Cari Produk !! </strong>
</td>
</tr>
<tr> <td> Name </td>
<td>
<?php
?>
<select id="comboKategori" name="comboKategori">
<option value="">- Pilih Produk Anda -</option>
<option value="1">Susu</option>
<option value="2">Vitamin dan Makanan bayi</option>
<option value="3">Perlengkapan Bayi</option>
<option value="4">Diapers</option>
</select>
</br>
<select id="comboMerk" name="dada">
<option value="">- Pilih Merk Produk -</option>
</select>
</td>
</tr>
<td></td>
<td> <input type="SUBMIT" name="SUBMIT" id="SUBMIT" value="search" > </td>
</table>
</form>
</td>
</tr>
<tr>
<td width='200'> ini adalah tempat untuk gambarnya
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</td>
<td width='500'>
<?php
$host ='localhost';
$user ='root';
$pass ='clasmild';
$dbase ='DaftarWaralaba';
$koneksi = mysql_pconnect($host, $user, $pass) or die(mysql_error());mysql_select_db($dbase, $koneksi);
$name= $_POST['dada']; //get the nama value from form
$q = "SELECT * from susu where name like '%$name%'";
$result = mysql_query($q);
echo "<center>";
echo "<h2> Hasil Pencarian </h2>";
echo "<table border='1' cellpadding='5' cellspacing='8'>";
echo "
<tr bgcolor='orange'>
<td>Nama Produk</td>
<td>Kategori</td>
<td>Harga</td>
</tr>";
while ($data = mysql_fetch_array($result)) { //fetch the result from query into an array
echo "
<tr>
<td>".$data['name']."</td>
<td>".$data['kategori']."</td>
<td>".$data['harga']."</td>
</tr>";
}
echo "</table>";
?>
</td>
</tr>
</table>
<br/>
<br/>
</body>
</html>
bisa lihat contohnya di video tutorial https://youtu.be/Cz0-1q8FvJ0