Tuesday, 17 November 2015

kode program cari pada php dengan contoh daftar barang

kode program cari 
<html>
<head>
<title></title>
</head>
<body>
<h1>Search</h1>
<form action="hasilcari.php" method="POST">
<p>

Jenis
  <input name="search" type="text" id="search" >
<label>

</label>
<input type="submit" name="cari" value="Cari">
</p>
<p>&nbsp;</p>
</form>
</body>
</html>

dan kode hasil cari 

<html>
<head>
<title>Daftar Barang</title>
</head>
<body>
<p>
  <?php
mysql_connect("localhost", "root", "") or die ("Gagal konek ke server.");
mysql_select_db("dbuas") or die ("Gagal membuka database.");
?>
</p>
<p align="center">MENU</p>
<table width="536" height="96" border="5" align="center">
<tr>
<th width="43" height="36">Kode</th>
<th width="102">Nama Produk </th>
<th width="50">Jenis</th>
<th width="82">Harga</th>
<th width="82">Rubah</th>
<th width="82">Hapus</th>
</tr>
<?php
$query = "select * from tabbarang";
$result = mysql_query($query);
while ($buff = mysql_fetch_array($result)){
?>
<tr>
<td><?php echo $buff['kode']; ?></td>
<td><?php echo $buff['namaproduk']; ?></td>
<td><?php echo $buff['jenis']; ?></td>
<td><?php echo $buff['harga']; ?></td>
<td width="43"><a href="edit.php?jenis=<?php echo $buff['jenis']; ?>">Rubah</a></td>
<td width="43"><a href="hapus.php?jenis=<?php echo $buff['jenis']; ?>">Hapus</a></td>
 </tr>
<?php
}
mysql_close();
?>
</table>
<p>&nbsp;</p>
<td><p align="center"><a href="tambah.php"> ADD</a> </p></td>
 <p><td><p align="center"><a href="cari.php"> SEARCH</a> </p></td>
</body>
</html>

No comments:

Post a Comment