<?php
				  if (isset($_GET['id']))
	{
 $dbc=mysqli_connect('localhost','jbxnmmli_spo','@@!@SWQ!Y6tgaq@!@','jbxnmmli_pso');
$messages_id = $_GET['id'];
$result = mysqli_query($dbc,("SELECT * FROM stocking where id='$messages_id'"));
while($row = mysqli_fetch_array($result))
  {
  $code=$row['product_id'];
  $f=$row['qty'];
   $number=$row['t_code'];
   $session=$row['session'];
  }
$result1 = mysqli_query($dbc,("SELECT * FROM products where product_id='$code'"));

while($row1 = mysqli_fetch_array($result1))
  {
  $pleft=$row1['left_p'];
    $name=$row1['p_name'];
  }
  
$dugang=$pleft-$f;

mysqli_query($dbc,("UPDATE products SET left_p = '$dugang'
WHERE product_id = '$code'"));

mysqli_query($dbc,("DELETE FROM stocking WHERE id='$messages_id'"));
mysqli_query($dbc,("DELETE FROM ledgers WHERE session='$session'"));
mysqli_query($dbc,("DELETE FROM audit where session='$session'limit 1"));
header("location: stocking.php");
mysqli_close($dbc);
}
?>