Pages

Wednesday, December 12, 2018

Membuat Cari PHP

Belajar menggunakan Dreamweaver. Tutorial yang mirip bisa klik di sini.

1. Konfigurasi
<?php
// koneksi mysql ke php
mysql_connect("localhost","root","");
mysql_select_db("stmikj");
?>

2. Tampilan
<html>
<body>
<?php 
include 'config.php';
?>

<h3>Form Pencarian</h3>

<form action="indeks.php" method="get">
<label>Cari :</label>
<input type="text" name="cari">
<input type="submit" value="Cari">
</form>

<?php 
if(isset($_GET['cari'])){
$cari = $_GET['cari'];
echo "<b>Hasil pencarian : ".$cari."</b>";
}
?>

<table border="1">
<tr>
<th>No</th>
<th>Nama</th>
</tr>
<?php 
if(isset($_GET['cari'])){
$cari = $_GET['cari'];
$data = mysql_query("select * from mhs where nama like '%".$cari."%'");
}else{
$data = mysql_query("select * from mhs");
}
$no = 1;
while($d = mysql_fetch_array($data)){
?>
<tr>
<td><?php echo $no++; ?></td>
<td><?php echo $d['nama']; ?></td>
</tr>
<?php } ?>
</table>

</body>
</html>


Bitcoin Offers:
Free Bitcoin, Double Bitcoin, Bitcoin Investment, Bitcoin Trading



"Bitcoin and Forex are high risk business. We must join them smartly."

No comments:

Post a Comment