Greetings. Well I am trying to make a page which will add a number to a special database table. Like a user on my site have 10 diamonds, but then when he visit a special link to get 5 extra diamonds. The database table is "players", and inside that there is the "diamonds". The user is definied as by the table "id". I want to run the command when the user access the page. The command should do the following: It should give the player with the ID="1" addiatinal 5 diamonds. Can anyone guide me to do this? As far as I got right now is this. (Thanks to Damdomy) mysql_query("UPDATE `players` SET `diamonds` = `diamonds` + 5"); PHP: The problem with this is that it gives every player + 5 diamonds, and it should only be the user with the ID set to 1. I got MSN, gTalk, Skype and TeamViewer.
Just need to put a WHERE clause. mysql_query("UPDATE `players` SET `diamonds` = `diamonds` + 5 WHERE uid = 1"); PHP:
Thanks a lot for the reply. I just tried this, but it doesn't work. Do I have to change the other of commands? Maybe something like this? mysql_query("UPDATE `players` WHERE uid = 1 SET `diamonds` = `diamonds` + 5"); PHP:
Mine should be right, though there may be a small error somewhere, try: mysql_query('UPDATE players SET diamonds=diamonds + 5 WHERE uid="1"') or die(mysql_error()); PHP: