RE: [PHP] mysql query for current id-1

From: Date: Tue, 02 Oct 2001 04:13:39 +0000
Subject: RE: [PHP] mysql query for current id-1
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-69537@lists.php.net to get a copy of this message
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:jdulberg@nas.net] Sent: martedì 2 ottobre 2001 6.04 To: php-general@lists.php.net 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: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#69537) next »