MadnessRed Posted June 24, 2008 Share Posted June 24, 2008 OK, I am still very new to this kinda thing. What i want to do is, add a number to an already existing number. Eg, if in the database it said 9, I could add 5 more to that. Is there a simple way to do this, or do I find the old value, add the new value to it, then write it, or can I just add it? Here is an example $old = $row['Description']; $plus = $_GET["plus"]; $new = $old + $plus; $query1 = "UPDATE `madnessred_sites` SET `Count` = '$new' WHERE `ID` ='$id'"; Could I instead do something like $query1 = "UPDATE `madnessred_sites` ADD TO `Count` = '$new' WHERE `ID` ='$id'"; Quote Link to comment Share on other sites More sharing options...
Barand Posted June 24, 2008 Share Posted June 24, 2008 $query1 = "UPDATE `madnessred_sites` SET `Count` = `Count` + $plus WHERE `ID` = '$id'"; Quote Link to comment Share on other sites More sharing options...
MadnessRed Posted June 24, 2008 Author Share Posted June 24, 2008 thanks also for a slightly different code, would this work $query1 = "UPDATE `madnessred_sites` SET `Count` = `Count` + '1' WHERE `ID` = '$id'"; Quote Link to comment Share on other sites More sharing options...
Barand Posted June 25, 2008 Share Posted June 25, 2008 yes. the quotes round '1' are unnecessary though as it's a numeric value Quote Link to comment Share on other sites More sharing options...
MadnessRed Posted June 25, 2008 Author Share Posted June 25, 2008 thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.