Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include 'koneksi.php';
  4. $username=$_SESSION['username'];
  5. $id_produk = $_GET['id'];
  6.  
  7. $total=0;
  8. $jumlah=0;
  9. $tanggal=date('Y-m-d');
  10. $query="SELECT * FROM produk WHERE id_produk='$id_produk'";
  11. $hasil=mysqli_query($koneksi,$query);
  12. while ($pecah=mysqli_fetch_array($hasil)) {
  13. $jumlah++;
  14. $subharga=$pecah["harga_baru"]*$jumlah;
  15.  
  16. $ambil=$koneksi->query("SELECT * FROM ongkir");
  17. while ($pecah2=$ambil->fetch_assoc()){
  18.  
  19. $total=$subharga+$ongkir; };
  20. };
  21.  
  22. $querycart="INSERT INTO transaksi (qty,subharga,ongkir,total,username,tanggal) VALUES ( '$jumlah', '$subharga', '$ongkir', '$total','$username', '$tanggal' )";
  23.  
  24. $hasilcart=mysqli_query($koneksi,$querycart);
  25.  
  26. if ($hasilcart) {
  27. header('location:nota.php');
  28. } else {
  29. echo "Gagal tambah produk";
  30. }
  31.  
  32.  
  33. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement