<!-- form advanced search -->
<form name="form1" method="get" action="">
nama : <input type="text" name="nama" id="nama"/> <br/>
nip : <input type="text" name="nip" id="nip"/> <br/>
lokasi_kerja : <input type="text" name="lokasi_kerja" id="lokasi_kerja"/> <br/>
<br/><input type="submit" value="Search" name="search"/>
</form>
<!-- menampilkan hasil pencarian -->
<?php
if(isset($_GET['search'])){
$mysqli = new mysqli("localhost", "root", "","simpeg");
$nama = $_GET['nama'];
$nip = $_GET['nip'];
$lokasi_kerja = $_GET['lokasi_kerja'];
$sql = "select * from tbdos where nama like '%$nama%' and
nip like '%$nip%' and lokasi_kerja like '%$lokasi_kerja%' ";
$result = $mysqli->query($sql);
if ($result->num_rows > 0){
?>
<table>
<tr>
<td>nama</td>
<td>nip</td>
<td>lokasi_kerja</td>
<td>Alamat</td>
</tr>
<?php
while($row = mysqli_fetch_array($result)){?>
<tr>
<td><?php echo $row['nama'];?></td>
<td><?php echo $row['nip'];?></td>
<td><?php echo $row['lokasi_kerja'];?></td>
</tr>
<?php }?>
</table>
<?php
}else{
echo 'Data not found!';
}
}
?>
<form name="form1" method="get" action="">
nama : <input type="text" name="nama" id="nama"/> <br/>
nip : <input type="text" name="nip" id="nip"/> <br/>
lokasi_kerja : <input type="text" name="lokasi_kerja" id="lokasi_kerja"/> <br/>
<br/><input type="submit" value="Search" name="search"/>
</form>
<!-- menampilkan hasil pencarian -->
<?php
if(isset($_GET['search'])){
$mysqli = new mysqli("localhost", "root", "","simpeg");
$nama = $_GET['nama'];
$nip = $_GET['nip'];
$lokasi_kerja = $_GET['lokasi_kerja'];
$sql = "select * from tbdos where nama like '%$nama%' and
nip like '%$nip%' and lokasi_kerja like '%$lokasi_kerja%' ";
$result = $mysqli->query($sql);
if ($result->num_rows > 0){
?>
<table>
<tr>
<td>nama</td>
<td>nip</td>
<td>lokasi_kerja</td>
<td>Alamat</td>
</tr>
<?php
while($row = mysqli_fetch_array($result)){?>
<tr>
<td><?php echo $row['nama'];?></td>
<td><?php echo $row['nip'];?></td>
<td><?php echo $row['lokasi_kerja'];?></td>
</tr>
<?php }?>
</table>
<?php
}else{
echo 'Data not found!';
}
}
?>
Comments
Post a Comment