Solved

I need some PHP code that will READ a value in a MySQL database and UPDATE value by 1

Posted on 2011-03-17
2
221 Views
Last Modified: 2012-05-11
I have a very simple web users database which a MySQL database called "users".  In the users database there is a table called "members" which stores usernames and passwords.  I added a new Field called "logins" so we could track the total number of logins by each user.

I need some PHP code that will increment the "logins" field each time a web user logins in.   Currently i have a checklogin.php file that registers the users session upon successful login.

Thanks
0
Comment
Question by:ipconfig610
2 Comments
 
LVL 27

Accepted Solution

by:
Lukasz Chmielewski earned 500 total points
ID: 35159310
Let's assume $islogged is the boolean value for the user to check if is logged or not and $userlogin is user login stored in a session / cookie

if($islogged){
 $query = "update users set logins = logins + 1 where $login = '$userlogin'";
 $result = mysql_query($query) or die(mysql_error());;
}
0
 
LVL 1

Expert Comment

by:bluedevil9
ID: 35159340
once the session is active, pull the "logins" value from the database of the particular user and increment the value and update the value using the update query.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now