How to introduce a php variable into an MySQL calculation?

me_patrick used Ask the Experts™
I want to set a field (column) with a new value partly based on the result of a calculation in php, e.g.   .... SET order_total      = (order_total + $adjustment) .....
but this didn't seem to work - how can I make that dynamic calculation work within the MySQL UPDATE statement?  
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Here is an example where $email is the variable

$sql = "SELECT `email`, `contactme` FROM `your_table` WHERE `email` = '$email' and `contactme` = '1'";

Open in new window

Ignore my previous post, didn't read the whole question.
Your going to have to calculate the adjustment from the order_total before inserting into the database. Something like:
$newtotal = order_total + $adjustment
Set order_total = $newtotal
mysql_query("UPDATE cikk SET sorszam=(sorszam+'".$nr."') where id_cikk='11'");


That's it - thanks.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial