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 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 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; 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! 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! 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
Archived
This topic is now archived and is closed to further replies.