What about this: $sql="select id,agent,host, DATE_FORMAT(time_in, '%M %d, %Y, %l:%i') AS unixdate from logged_in WHERE userid='$current_user' ORDER BY id DESC LIMIT 1"; I think this should work for your case. Maxim Maletsky www.PHPBeginner.com -----Original Message----- From: Jason Dulberg [mailto:[EMAIL PROTECTED]] Sent: marted́ 2 ottobre 2001 6.04 To: [EMAIL PROTECTED] Subject: [PHP] mysql query for current id-1 This is kindof a weird question so bear with me as I try to explain. I have a session table that gets updated when a user logs in/out. If they don't logout, some info is left unchanged. I have a cron script that takes care of the stray sessions so that's all good. In the sessions table, there's a field "self_logout" which is Y when they logout properly and N if the cron script removes their session. What I'd like to do is when the user logs in next time, a search will be made to look at that users last login session info. If they didn't log out properly, a notice will appear. So theoretically, I need to search for something like: "users current id -1" or their last time of visit. Here is the sql query that I have so far. But I think that I need to remove the "self_logout='N'" because that doesn't show the actual last result; rather it shows the last result where they didn't properly logout. $sql="select id,agent,host, DATE_FORMAT(time_in, '%M %d, %Y, %l:%i') AS unixdate from logged_in WHERE (self_logout='N') AND (userid='$current_user') ORDER BY id DESC LIMIT 1,1"; Here is my trimmed down table structure: CREATE TABLE logged_in ( id tinyint(4) DEFAULT '0' NOT NULL auto_increment, session varchar(100) DEFAULT '0' NOT NULL, time_in timestamp(14), time_out varchar(50) DEFAULT '-' NOT NULL, self_logout char(1) DEFAULT 'N' NOT NULL, KEY id (id) ); Did that make any sense? To sum it all up, I just want to remind people to click "logout" if they forgot the last time. Thanks for any suggestions!! __________________ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] mysql query for current id-1
Maxim Maletsky \(PHPBeginner.com\) Mon, 01 Oct 2001 20:45:26 -0700
- [PHP] mysql query for current id-1 Jason Dulberg
- Re: [PHP] mysql query for current ... Mukul Sabharwal
- RE: [PHP] mysql query for current ... Maxim Maletsky \(PHPBeginner.com\)
- RE: [PHP] mysql query for current ... Jason Dulberg
- RE: [PHP] mysql query for current ... Maxim Maletsky \(PHPBeginner.com\)
- RE: [PHP] mysql query for current ... Jason Dulberg