Tuesday, 17 November 2015
kode program edit php dengan contoh tabel barang
from edit tabel barang
<?php
include("koneksi.php");
$jenis = $_GET['jenis'];
$query = "select * from tabbarang where jenis='$jenis'";
$result = mysql_query($query) or die("gagal melakukan query");
$buff = mysql_fetch_array($result);
mysql_close();
?>
<html>
<head><title>Edit Data</title></head>
<body>
<form name="form1" method="post" action="update.php">
<table>
<tr>
<td>Kode</td>
<td><input type="text" name="kode" value="<?php echo $buff['kode']; ?>"></td></tr>
<tr><td>Nama Produk </td>
<td><input type="text" name="namaproduk" value="<?php echo $buff['namaproduk']; ?>"></td></tr>
<tr>
<td>Jenis</td>
<td><input type="text" name="jenis" value="<?php echo $buff['jenis']; ?>" ></td></tr>
<tr>
<td>Harga</td>
<td><input type="text" name="harga" value="<?php echo $buff['harga']; ?>" ></td></tr>
<tr><td> </td>
</tr>
<tr>
</table>
<label>
<input type="submit" name="Submit" value="Simpan">
</label>
<p> </p>
</form>
</body>
</html>
include("koneksi.php");
$jenis = $_GET['jenis'];
$query = "select * from tabbarang where jenis='$jenis'";
$result = mysql_query($query) or die("gagal melakukan query");
$buff = mysql_fetch_array($result);
mysql_close();
?>
<html>
<head><title>Edit Data</title></head>
<body>
<form name="form1" method="post" action="update.php">
<table>
<tr>
<td>Kode</td>
<td><input type="text" name="kode" value="<?php echo $buff['kode']; ?>"></td></tr>
<tr><td>Nama Produk </td>
<td><input type="text" name="namaproduk" value="<?php echo $buff['namaproduk']; ?>"></td></tr>
<tr>
<td>Jenis</td>
<td><input type="text" name="jenis" value="<?php echo $buff['jenis']; ?>" ></td></tr>
<tr>
<td>Harga</td>
<td><input type="text" name="harga" value="<?php echo $buff['harga']; ?>" ></td></tr>
<tr><td> </td>
</tr>
<tr>
</table>
<label>
<input type="submit" name="Submit" value="Simpan">
</label>
<p> </p>
</form>
</body>
</html>
dan php update
<?php
include("koneksi.php");
$kode = $_POST['kode'];
$namaproduk = $_POST['namaproduk'];
$jenis = $_POST['jenis'];
$harga = $_POST['harga'];
mysql_query("update tabbarang set kode='$kode', namaproduk='$namaproduk', harga='$harga' where jenis='$jenis'");
echo "Data Telah diupdate<br>
<a href=\"menuutama.php\">Kembali</a>";
?>
include("koneksi.php");
$kode = $_POST['kode'];
$namaproduk = $_POST['namaproduk'];
$jenis = $_POST['jenis'];
$harga = $_POST['harga'];
mysql_query("update tabbarang set kode='$kode', namaproduk='$namaproduk', harga='$harga' where jenis='$jenis'");
echo "Data Telah diupdate<br>
<a href=\"menuutama.php\">Kembali</a>";
?>
sesuaikan dengan nama database
Labels:
pemograman ku
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment