In this discussion we will discuss the scripts used to make a quick search by providing key words to search
Example : Create quick search on mahasiswa table
<form name="formku"
method="get" action="">
Search : <input type="text"
name="q" id="q"/> <input type="submit"
value="Search"/>
</form>
<!-- menampilkan hasil pencarian -->
<?php
$q = $_GET['q'];
$sql = "select
* from mahasiswa where nama like '%$q%' or
nim like '%$q%' or fakultas like '%$q%' or alamat like '%$q%'";
?>
<table>
<tr>
<td>Nama</td>
<td>Nim</td>
<td>Fakultas</td>
<td>Alamat</td>
</tr>
<?php
<tr>
<td><?php echo $record['nama'];?></td>
<td><?php echo $record['nim'];?></td>
<td><?php echo $record['fakultas'];?></td>
<td><?php echo $record['alamat'];?></td>
</tr>
<?php }?>
</table>
<?php
}else{
echo 'Data
not found!';
}
}
?>
No comments:
Post a Comment