|
-
Dec 27th, 2010, 06:11 PM
#1
Thread Starter
Fanatic Member
everytime a submit button is pushed it will add a 1 to the mysql database?
Hi guys,
I am wondering if anybody can help me as i've been looking for hours now and cant find anything!
I basically have a site, where users can sign up and login. Now in the username table, i've added a bit on to each user called 'points'
which is automatically set at 0 -
now what i want is when the user is logged in, when the user clicks a submit button.
it will add a 1 to the points part ONLY for that user.
i.e it then turns to 1, if they press it again itll turn to 2 so on , so on.
How do i go about this?
Thanks,
Jamie,
-
Dec 27th, 2010, 07:41 PM
#2
Re: everytime a submit button is pushed it will add a 1 to the mysql database?
You retrieve the current value for the user, put the value into a variable.
$var++; and you do an UPDATE statement with that variable.
Delete it. They just clutter threads anyway.
-
Dec 27th, 2010, 09:51 PM
#3
Re: everytime a submit button is pushed it will add a 1 to the mysql database?
It's simpler to just use SQL. Example:
Code:
UPDATE myTable SET points=points+1 WHERE username='theUser'
-
Jan 6th, 2011, 04:55 AM
#4
Thread Starter
Fanatic Member
Re: everytime a submit button is pushed it will add a 1 to the mysql database?
Hey Guy's thanks for the replys!
So this is what i've got so far -
<?php mysql_query("UPDATE vital_vip.users SET points=points+1 WHERE id='$_SESSION[user_id]'") or die(mysql_error()); ?>
now, the code does work, when i make it use a form and a submit button, How ever now im wondering how i can make it, so that when the user goes on the page, it will run that code, and add the point,
At the moment the page is loading but it is not updating the points table,
Any idea why?
Thanks,
Jamie
-
Jan 6th, 2011, 05:06 AM
#5
Re: everytime a submit button is pushed it will add a 1 to the mysql database?
Use it at the start of the page that you want to count.
Just make sure the database connection is already open.
Delete it. They just clutter threads anyway.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|