Tom Read Posted January 12, 2011 Share Posted January 12, 2011 Hi. I'm doing a project at college, making a snooker league website. I have a form that has Team, Player and High Break. When submitted, they're stored in a database. This also updates the 'Player Stats' table. What I want to do is for the High Break column in the Player Stats table to update if the high break entered is greater than the value in the table already. For instance, if it says: Tom Read | 43, and in the form I type 36, I want it to remain as 43. If however a break for Tom Read added is 70, I want it to replace the 43. I can't quite get it right though! I want to say something along the lines of: mysql_query ("UPDATE player_table SET High_Break = $high_break IF $high_break > col_value WHERE Player_Name = '$player_name'"); Help would be appreciated, thanks Quote Link to comment https://forums.phpfreaks.com/topic/224198-help-please-update-set-col_name-if-something/ Share on other sites More sharing options...
Pikachu2000 Posted January 12, 2011 Share Posted January 12, 2011 Not certain this is what you're looking for, but according to the information you provided . . . "UPDATE player_table SET High_Break = $high_break WHERE Player_Name = '$player_name' AND $high_break > High_Break" Quote Link to comment https://forums.phpfreaks.com/topic/224198-help-please-update-set-col_name-if-something/#findComment-1158412 Share on other sites More sharing options...
Tom Read Posted January 12, 2011 Author Share Posted January 12, 2011 So simple! Why I couldn't do that I'll never know, thanks alot! Quote Link to comment https://forums.phpfreaks.com/topic/224198-help-please-update-set-col_name-if-something/#findComment-1158423 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.