-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
45 lines (43 loc) · 1.32 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
include ('config/connection.php');
$stmt = $connection->prepare("SELECT * FROM barang");
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Belajar CRUD - List Barang</title>
</head>
<body>
<table style="width:50%">
<tr>
<th>No</th>
<th>Kode Barang</th>
<th>Nama Barang</th>
<th>Stok</th>
<th>Harga</th>
<th>Action</th>
</tr>
<?php foreach ($result as $key => $data) { ?>
<tr>
<td><?php echo $key+1 ?></td>
<td><?php echo $data['kode'] ?></td>
<td><?php echo $data['nama'] ?></td>
<td><?php echo $data['stok'] ?></td>
<td><?php echo $data['harga'] ?></td>
<td>
<a href="edit.php?id=<?php echo $data['id'] ?>">Edit</a>
<form action="proses/delete.php?id=<?php echo $data['id']?>" method="post">
<button type="submit" name="delete">Delete</button>
</form>
</td>
</tr>
<?php } ?>
</table>
</body>
</html>