Tuesday, April 29, 2014

2 Button Proses Dalam 1 Form

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Latihan Database</title>
<style type="text/css">
#tampil { width:80px; }
</style>
<?php
//membuat koneksi dengan mysql
mysql_connect("localhost","root","");
//mebuka file basis data penjualan
mysql_select_db("penjualan");
//membuat query untuk tabel
$dt = mysql_query("select * from barang");
?>
</head>
<body>
<div align="center"></div>
<?php
//memindahkan data dari field(tabel ke variabel)
echo
"<table  border='1' align='center' cellpadding='5' cellspacing='0' width='700'>
<tr>
    <td>kode</td>
    <td>Nama</td>
    <td>Jenis</td>
    <td>Harga</td>
    <td>Stok</td>
    <td><table  border='0' cellspacing='0' width='0'><tr><td><form action='formisi.php'><input id='tampil' type='submit' value='INPUT'/></form></td><td><form action='cari.php'><input type='submit' value='CARI' /></form></td></table></td>
 </tr>";
//menampilkan data yang ada di dalam tabel
while ($data = mysql_fetch_array($dt)) {
?>
  <tr>
    <td><?php echo $data['kodebrg']; ?></td>
    <td><?php echo $data['namabrg']; ?></td>
    <td><?php echo $data['jenisbrg']; ?></td>
    <td><?php echo $data['hargabrg']; ?></td>
    <td><?php echo $data['stokbrg']; ?></td>
    <td><table border="0"><tr><td><form method="post" action="rubah.php?kdbrg=<?php echo $data['kodebrg']; ?>">
      <input name="submit" type="submit" id="tampil" value="RUBAH"/>
    </form></td><td><form method="post" action="hapus.php?hapus=<?php echo $data['kodebrg']; ?>"><input type="submit" value="HAPUS" /></form></td></tr></table></td>
 </tr>
<?php
}
echo "</table>";
?>
</body>
</html>

0 comments:

Post a Comment