Forum Moderators: coopster

Message Too Old, No Replies

How To Adjust stock quantities when sold

continued...

         

curlykarl

3:20 pm on Mar 3, 2005 (gmt 0)

10+ Year Member



Hi,

I have already sought assistance on this problem here..

[webmasterworld.com ]

But I'm still having problems resolving it. The code I have is

if ((isset($HTTP_POST_VARS["MM_update"])) && ($HTTP_POST_VARS["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE live_stock SET qty=-%s WHERE part_number=%s",
GetSQLValueString($HTTP_POST_VARS['qty'], "int"),
GetSQLValueString($HTTP_POST_VARS['partnumber'], "text"));

Its working to the extent that the entered value is being deducted, but not from the original stock level.

It zeros the stock level and takes away the entered value, so I start off with 5, sell 5 and the stock total goes to -5 and not 0?

Any clues would be appreciated.

Thanks

Karl

jusdrum

5:14 pm on Mar 3, 2005 (gmt 0)

10+ Year Member



Try this:

$updateSQL = sprintf("UPDATE live_stock SET qty = (qty - %s) WHERE part_number=%s",
GetSQLValueString($HTTP_POST_VARS['qty'], "int"),
GetSQLValueString($HTTP_POST_VARS['partnumber'], "text"));

curlykarl

5:49 pm on Mar 3, 2005 (gmt 0)

10+ Year Member



Jusdrum,

Just the job, can you beleive I have spent the last 8 1/2 hours chopping and changing the code to no avail!

Thank you for very much indeed for your advice.

Regards

Karl :)