<?php
$id=$_POST["id"];
$txt_box=$_POST["txt_box"];
if($id!=""){
$sql=" SELECT amount FROM table WHERE id='".$id."' ";
$qr=mysql_query($sql) or die (mysql_error());
$fetch=mysql_fetch_assoc($qr);
$amount=$fetch["amount"];
if($qr){
$total_update=$amount-$txt_box;
$sql1=" UPDATE table SET amount='".$total_update."' WHERE id='".$id."' ";
$qr1=mysql_query($sql1) or die (mysql_error());
if($qr1){
echo "UPDATE OK";
}else{
echo "UPDATE NOT OK";
}
}
}
?>