Dear Guru U can "update" the record with following =========== $result = mysql_query("UPDATE tax set mwool40_ totqty = $res", $connection) or die("error updating database"); if (mysql_affected_rows($connection) != 1 (/* no of rows that should be updated */) { die("Update problem") ; } The only issue is the where condition that you would put in the query UPDATE tax set mwool40_totqty = $res where ... ============ regds amit "The difference between fiction and reality? Fiction has to make sense." 2011/11/11 Guru™ <nagendra802000@xxxxxxxxx> > Hi All, > > I want to update an existing mysql record with another value after > calculating it. Below is the code. > > <?php > $connection = mysql_connect("localhost", "root", "") or die("Error > connecting to database"); > mysql_select_db("maha", $connection); > $result = mysql_query("SELECT * FROM tax", $connection) or die("error > querying database"); > $i = 0; > while($result_ar = mysql_fetch_assoc($result)){ > ?> > <tr <?php if($i%2 == 1){ echo "class='body2'"; }else{echo > "class='body1'";}?>> > <td> > <?php > $res=$result_ar['mwool40_totqty']-10; > echo $res; > ?></td> > </tr> > <?php > $i+=1; > } > ?> > > > I want to append the $mwool40_totqty value with the calculated one "$res". > Let say initially the value of $mwool40_totqty is 50. and after calculation > its value became 40, then the code should edit/alter/update the value in > mysql table with integer 40. Please help me with this. > > > -- > *Best, > * > *Guru™* >