-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete_peminjaman.php
28 lines (24 loc) · 1.2 KB
/
delete_peminjaman.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
<?php
include("connect.php");
$id = $_GET['id'];
$jumlah_dipinjam = mysqli_query($conn, "select * FROM peminjaman WHERE id_peminjaman=$id");
$data_pinjam = mysqli_fetch_assoc($jumlah_dipinjam);
$id_brng = (int)$data_pinjam['id_barang'];
$sql_jumlah = mysqli_query($conn,"select * from barang where id = $id_brng");
$data = mysqli_fetch_assoc($sql_jumlah);
$nama=$data['nama_barang'];
$jumlah=$data['jumlah'];
$jumlah_servis=$data['jumlah_servis'];
$jumlah_pinjam=$data['jumlah_pinjam']-$data_pinjam['jumlah'];
$jumlah_rusak=$data['jumlah_rusak'];
$tahun=$data['tahun_beli'];
$owner=$data['owner'];
$lokasi=$data['lokasi'];
$sql = "update history set status = 1 where id_peminjaman='$id'";
$perintah = "UPDATE barang SET nama_barang='$nama',jumlah=$jumlah,jumlah_rusak=$jumlah_rusak,jumlah_pinjam=$jumlah_pinjam,jumlah_servis=$jumlah_servis,tahun_beli='$tahun', owner='$owner', lokasi='$lokasi' where id=$id_brng";
$dum = mysqli_query($conn, $perintah);
$dum2= mysqli_query($conn, $sql);
$result = mysqli_query($conn, "DELETE FROM peminjaman WHERE id_peminjaman=$id");
$result = mysqli_query($conn, "DELETE FROM history WHERE id_peminjaman=$id");
header("Location:tabel_peminjaman.php");
?>