knoxinator Posted May 12, 2015 Share Posted May 12, 2015 I need help on the code for adding int values to a database. I am keeping scores each week for a poker club and each week I need to add the scores into the database so that it shows the total on the webpage. The page would look like this Name: Score: and the total scores page would be a table with the name on the left and total score on the right. It is very important that I can add scores each week that add on top of the total score for that player. Cheers Also the tables have already been created on mySQL Link to comment https://forums.phpfreaks.com/topic/296223-php-database-help/ Share on other sites More sharing options...
QuickOldCar Posted May 12, 2015 Share Posted May 12, 2015 Minimal response for a minimal question. $sql = "UPDATE table_nameSET score='score+".$score."'WHERE user='".$user."'"; If you need whole numbers can use ROUND() Link to comment https://forums.phpfreaks.com/topic/296223-php-database-help/#findComment-1511490 Share on other sites More sharing options...
mac_gyver Posted May 12, 2015 Share Posted May 12, 2015 you should store the raw data for each week/game/player as a separate row in a 'result' table, similar to what you do with a bank account statement. then simply do a sum() in a query to produce a score for any player(s) when needed. this will do two things - 1) keep a specific record of who, what, when, and where something occurred 2) prevent duplicate entries/processing from corrupting the data. Link to comment https://forums.phpfreaks.com/topic/296223-php-database-help/#findComment-1511500 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.