data-barang.php

 avatar
unknown
php
3 years ago
1.2 kB
27
Indexable
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Data Barang</title>
</head>
<body>
<h2> Data Barang</h2>
<table border="1">
	<tr>
		<th>No</th>
		<th>Kode Barang</th>
		<th>Nama Barang</th>
		<th>Harga Barang</th>
		<th>Aksi</th>
	</tr>

<?php
include "koneksi.php";
$no=1;
$ambildata = mysqli_query($koneksi,"select * FROM barang");
while ($tampil = mysqli_fetch_array($ambildata)){
	echo "
	<tr>
		<td>$no</td>
		<td>$tampil[kode_barang]</td>
		<td>$tampil[nama_barang]</td>
		<td>$tampil[harga_barang]</td>
		<td>
		<a href='?kode=$tampil[kode_barang]'> Hapus </a> |
		<a href='barang-edit.php?=$tampil[kode_barang]'> Edit </a>
		</td>
	</tr>
	";
	$no++;
}
?>
<p><a href="barang-tambah.php">Tambah Barang</a></p>
</table>

<?php
    include "koneksi.php";

    if(isset($_GET['kode'])){
    mysqli_query($koneksi,"delete from barang where kode_barang='$_GET[kode]'");
    
    echo "Data berhasil dihapus";
    echo "<meta http-equiv=refresh content=2;URL='data-barang.php'>";

    }
    ?>
    
</body>
</html>
Editor is loading...