Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'config/connection.php';
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>Document</title>
- </head>
- <body>
- <center><h1>DATA PRODUCTS</h1></center>
- <a href = "add_product.php"><p align ="right"><button>Add Data Product</button></p></p></a>
- <table align = "center" width="95%" border = "1">
- <tr>
- <td>No</td>
- <td>Nama Suplier</td>
- <td>Brand</td>
- <td>Price</td>
- <td>Volume</td>
- <td>Created</td>
- <td>Modified</td>
- <td>Action</td>
- </tr>
- <?php
- $no = 1;
- $sql = "SELECT s.name, p.* FROM products p, supliers s WHERE s.id = p.suplier_id"; //membuat query
- //echo $sql;
- $exe = mysqli_query($conn, $sql); // menjalankan query
- while($row = mysqli_fetch_array($exe)){
- // $id_sup = $row['suplier_id'];
- // $sql_sup = "SELECT name FROM supliers WHERE id = '$id_sup'";
- //echo $sql_sup;
- // $exe_sup = mysqli_query($conn, $sql_sup);
- // $row_sup = mysqli_fetch_array($exe_sup);
- ?>
- <tr>
- <td><?=$no++?></td>
- <td><?=$row['name']?></td>
- <td><?php echo $row['brand'];?></td>
- <td><?=$row['price']?></td>
- <td><?php echo $row['volume'];?></td>
- <td><?php echo $row['created'];?></td>
- <td><?php echo $row['modified'];?></td>
- <td>Edit | <a href = "product_delete.php?ganteng='<?=$row['id']?>'">DELETE</a></td>
- </tr>
- <?php
- }
- ?>
- </table>
- </body>
- </html>
- product_delete.php
- <?php
- include "config/connection.php";
- $id = $_GET['ganteng'];
- //echo $id;
- $query = "DELETE FROM products WHERE id = $id";
- //echo $query;
- $exe = mysqli_query($conn, $query);
- if ($exe) {
- # code...
- echo "<script>alert('Hapus data berhasil'); document.location.href = 'products.php';</script>";
- }else{
- echo "<script>alert('Hapus data gagal'); document.location.href = 'products.php';</script>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement