dreamwest Posted January 10, 2009 Share Posted January 10, 2009 I want to update values everytime a script runs Example: $result = mysql_query("UPDATE video SET viewnumber='2' WHERE viewnumber='0'") or die(mysql_error()); Im trying to increase the number by 2 everytime the script runs. But i cant see how i can do this when WHERE viewnumber='0' can be any number Quote Link to comment https://forums.phpfreaks.com/topic/140289-solved-update-values-everytime-a-script-runs/ Share on other sites More sharing options...
bubbasheeko Posted January 10, 2009 Share Posted January 10, 2009 $result = mysql_query("UPDATE video SET viewnumber='2'"); That's what you need to do based on how you described it. It doesn't matter what viewnumber is, you just want to increase it by two. But i cant see how i can do this when WHERE viewnumber='0' can be any number Quote Link to comment https://forums.phpfreaks.com/topic/140289-solved-update-values-everytime-a-script-runs/#findComment-734083 Share on other sites More sharing options...
corbin Posted January 10, 2009 Share Posted January 10, 2009 $result = mysql_query("UPDATE video SET viewnumber='2'"); That's what you need to do based on how you described it. It doesn't matter what viewnumber is, you just want to increase it by two. But i cant see how i can do this when WHERE viewnumber='0' can be any number That will set it to 2 every load. I think he wants to increase it by 2. UPDATE video SET viewnumber = viewnumber + 2; Quote Link to comment https://forums.phpfreaks.com/topic/140289-solved-update-values-everytime-a-script-runs/#findComment-734092 Share on other sites More sharing options...
dreamwest Posted January 10, 2009 Author Share Posted January 10, 2009 That will set it to 2 every load. I think he wants to increase it by 2. UPDATE video SET viewnumber = viewnumber + 2; This works. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/140289-solved-update-values-everytime-a-script-runs/#findComment-734095 Share on other sites More sharing options...
bubbasheeko Posted January 10, 2009 Share Posted January 10, 2009 LOL That's right. Thanks for the correction! Quote Link to comment https://forums.phpfreaks.com/topic/140289-solved-update-values-everytime-a-script-runs/#findComment-734107 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.