1) Collect data from a form and used POST data to take that entry and subtract it against the total current QTY in my MySQL Database.
2) Update the two tables (SNAInv and SNAInvHist(this table is the transactions of the add/subtracts from each item in the main INV db)
3) tell it completed.
The problem is the only thing NOT working is the subtraction... I get a big fat NADA.
Here is the form:
Code: Select all
<html><head><title>Inventory</title></head> <body bgcolor="#C0C0C0"><img border="0" src="logo1.jpg" width="78" height="77"> <font face="Arial" color="#000080">Inventory - Managing Inventory Input</font><font face="Arial" color="#000080"><P> <form method="POST" name="Recv" action="queryme.php"> <table width="550" border="0" cellspacing="2" cellpadding="3"> <tr> <td colspan="2" bgcolor="#000000"><span class="style1">Managing Inventory Control</span></td> </tr> <tr> <td bgcolor="#FFCC66">Part Number: </td> <td bgcolor="#CCCCCC"><input name="ProdNum" type="text" id="ProdNum"></td> </tr> <tr> <td width="159" bgcolor="#FFCC66">Part Description:</td> <td width="373" bgcolor="#CCCCCC"><input name="ProdDesc" type="text" id="ProdDesc"></td> </tr> <tr> <td bgcolor="#FFCC66">Amount Consumed: </td> <td bgcolor="#CCCCCC"><input name="Consumed" type="int" id="Consumed"></td> </tr> <tr> <td> </td> <td><input type="submit" value="Submit Modifications" /></td> </tr></table> </form></body></html>Code: Select all
<?php
// Connect to mysql database
$con = mysql_connect("localhost","user","password") or die('Connection: ' . mysql_error());;
mysql_select_db("logdata", $con) or die('Database: ' . mysql_error());
mysql_select_db("logdata", $con);
// Insert form values into database
$copy = mysql_fetch_array(mysql_query("SELECT * FROM `SNAInv` WHERE `ProdNum`= '$_POST[ProdNum]'")) or die(mysql_error());
// ^^ SELECT THE DATA TO BE COPIED ^^
$sqlrun = mysql_query("UPDATE `SNAInv` SET `QtyOnHand` = `$copy[QtyOnHand]` - `". $_POST[Consumed] ."` WHERE `ProdNum` = `$_POST[ProdNum]`");
$sql = @mysql_query("INSERT INTO `SNAInvHist` (`ProdNum`, `ProdDesc`, `QtyOnHand`, `Consumed`, `RecvDate`, `ConSumDate`) VALUES ('" . $copy['ProdNum'] . "', '" . $copy['ProdDesc'] . "', '" . $sqlrun['QtyOnHand'] . "', '". $_POST[Consumed] ."', '". $copy[RecvDate] ."', Now())") or die(mysql_error());
echo "Inventory For Part Number:\n".$copy[ProdNum]." has been modified and a Transaction has been recorded ";
echo "
new Quantity is:\n".$sqlrun[QtyOnHand]."";
mysql_close($con);
?>
<p>Return to Manage Inventory Control</p>What am I missing?
Thanks,
Texman