<?php $number=$_POST['number'];//get the number from POST settype($number, "integer");//make sure it's a number not a string .. $conn = mysql_connect("localhost", "user", "pass"); mysql_select_db("DB",$conn); $sql = "INSERT INTO Table values ('', number=number-$number)"; /*notice that you don't need any quote here just call 'number' from database and use it again in the same query and substract $number from it .. ot use any other algebra ..*/ if (mysql_query($sql, $conn)) { echo "record added!"; } else { echo "something went wrong"; } ?>