close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues


update stock qty using mysqli

Thread began 6/22/2017 6:31 am by CraigR | Last modified 6/22/2017 5:53 pm by Ray Borduin | 560 views | 2 replies |

CraigRBeta Tester

update stock qty using mysqli

I am pretty familiar with the WA Mysqli extension, but I cant work out the syntax for this one.

on a checkout success page, i want to loop through the cart content and update the stock quantity of all items purchased.

it is pretty straightforward to update the stock qty field to a set value, but i want it updated to a calculated value, ie current stock qty - qty purchased

Can someone please help me determine what syntax I need for the 3rd input ($paramValue)

//loop through the cart so we know what ItemIDs have been purchased
// update the quantities in table
$inthecart = '';
$inthecartqty = '';
while (!$schoolshopcart->EOF()) {
$inthecart = $schoolshopcart->DisplayInfo("ID");
$inthecartqty = $schoolshopcart->DisplayInfo("Quantity");

$UpdateQuery = new WA_MySQLi_Query($PowerCMSConnection_i);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = "tblitemculford";
$UpdateQuery->bindColumn("ItemQty", "i", $paramValue, "WA_DEFAULT");
$UpdateQuery->addFilter("ItemID", "=", "i", "".($inthecart) ."");
$UpdateGoTo = "";
if (function_exists("rel2abs")) $UpdateGoTo = $UpdateGoTo?rel2abs($UpdateGoTo,dirname(__FILE__)):"";


I tried $UpdateQuery->bindColumn("ItemQty", "i", "ItemQty" - $inthecartqty, "WA_DEFAULT");

but this doesn;t bind the field in the calculation

the sql statement i am essentially trying to generate looks like this...

UPDATE tblitemculford SET ItemQty = ItemQty - ".$inthecartqty." WHERE ItemID =".$inthecart
Sign in to reply to this post

Ray BorduinWebAssist

You would have to do this manually like:


= new WA_MySQLi_Query($PowerCMSConnection_i);
$CustomQuery->Statement "UPDATE tblitemculford SET ItemQty = ItemQty - ? WHERE ItemID = ?";
Sign in to reply to this post

CraigRBeta Tester

thanks Ray - works for me

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...