Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.33 KB | None | 0 0
  1. <?php
  2.     include 'config/connection.php';
  3. ?>
  4. <!DOCTYPE html>
  5. <html lang="en">
  6. <head>
  7.     <meta charset="UTF-8">
  8.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  9.     <meta http-equiv="X-UA-Compatible" content="ie=edge">
  10.     <title>Document</title>
  11. </head>
  12. <body>
  13.     <center><h1>DATA PRODUCTS</h1></center>
  14.     <a href = "add_product.php"><p align ="right"><button>Add Data Product</button></p></p></a>
  15.     <table align = "center" width="95%" border = "1">
  16.         <tr>
  17.             <td>No</td>
  18.             <td>Nama Suplier</td>
  19.             <td>Brand</td>
  20.             <td>Price</td>
  21.             <td>Volume</td>
  22.             <td>Created</td>
  23.             <td>Modified</td>
  24.             <td>Action</td>
  25.         </tr>
  26.         <?php
  27.             $no = 1;
  28.             $sql = "SELECT s.name, p.* FROM products p, supliers s WHERE s.id = p.suplier_id"; //membuat query
  29.             //echo $sql;
  30.             $exe = mysqli_query($conn, $sql); // menjalankan query
  31.             while($row = mysqli_fetch_array($exe)){
  32.                // $id_sup = $row['suplier_id'];
  33.               //  $sql_sup = "SELECT name FROM supliers WHERE id = '$id_sup'";
  34.                 //echo $sql_sup;
  35.               //  $exe_sup = mysqli_query($conn, $sql_sup);
  36.               //  $row_sup = mysqli_fetch_array($exe_sup);
  37.         ?>
  38.         <tr>
  39.             <td><?=$no++?></td>
  40.             <td><?=$row['name']?></td>
  41.             <td><?php echo $row['brand'];?></td>
  42.             <td><?=$row['price']?></td>
  43.             <td><?php echo $row['volume'];?></td>
  44.             <td><?php echo $row['created'];?></td>
  45.             <td><?php echo $row['modified'];?></td>
  46.             <td>Edit | <a href = "product_delete.php?ganteng='<?=$row['id']?>'">DELETE</a></td>
  47.         </tr>
  48.         <?php
  49.             }
  50.         ?>
  51.     </table>
  52. </body>
  53. </html>
  54.  
  55.  
  56.  
  57. product_delete.php
  58. <?php
  59.     include "config/connection.php";
  60.  
  61.     $id = $_GET['ganteng'];
  62.     //echo $id;
  63.  
  64.     $query = "DELETE FROM products WHERE id = $id";
  65.  
  66.     //echo $query;
  67.     $exe = mysqli_query($conn, $query);
  68.     if ($exe) {
  69.         # code...
  70.        echo "<script>alert('Hapus data berhasil'); document.location.href = 'products.php';</script>";
  71.     }else{
  72.         echo "<script>alert('Hapus data gagal'); document.location.href = 'products.php';</script>";
  73.        
  74.     }
  75.  
  76. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement