Commit 3a708ee3 authored by trh010's avatar trh010

fixed bug on stock_shelves

parent a253e407
<?php
ob_start();
session_start();
$conn = mysql_connect("db.eg.bucknell.edu",$_SESSION["user"],$_SESSION["pwd"]);
if (!$conn) die("Cound not connect to database");
session_start();
$conn = mysql_connect("db.eg.bucknell.edu",$_SESSION["user"],$_SESSION["pwd"]);
if (!$conn) die("Cound not connect to database");
mysql_select_db($_SESSION["database"]) or die("Unable to select database");
$item = $_POST['item'];
......@@ -13,6 +13,11 @@
if (!$result) die("Query1 failed!" . mysql_error());
$row = mysql_fetch_row($result);
$num_in_stock = intval($row[0]);
$result = mysql_query("SELECT DISTINCT count FROM GroceryShelves WHERE item='$item';");
if (!$result) die("Query1 failed!" . mysql_error());
$row = mysql_fetch_row($result);
$num_on_shelves = intval($row[0]);
//echo "<br>".$item . "<br>" . $quantity . "<br>" . $num_in_stock . "<br>";
......@@ -20,7 +25,7 @@
if($num_in_stock > $quantity and $num_in_stock > 0){
// update GroceryShelves
$new_onShelves_quant = $num_in_stock + $quantity;
$new_onShelves_quant = $num_on_shelves + $quantity;
//echo $new_onShelves_quant . "<br>";
$result = mysql_query("UPDATE GroceryShelves SET GroceryShelves.count=($new_onShelves_quant) WHERE item='$item';");
if (!$result) die("Query2 failed!" . mysql_error());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment