RE: [PHP] select based on time/date

From: Date: Wed, 26 Sep 2001 17:44:32 +0000
Subject: RE: [PHP] select based on time/date
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-68901@lists.php.net to get a copy of this message
You were right! I changed it to a timestamp (14) and the selection is working great now. Only problem is that when I logout which UPDATE's the table to clear the $session field, the $time_in timestamp gets updated because of the NOW() function. I need that date to stay the same when someone logs out. current logout.php: $out = "UPDATE logged_in SET session='' WHERE (logged_in.userid='$aid') AND (logged_in.session='$sessid')"; Is there a way to only allow the NOW() to work when a row is added to the table? Or perhaps another way.... Thank you again for your time. I've learned alot from this. __________________ Jason Dulberg Extreme MTB http://extreme.nas.net > -----Original Message----- > From: Sheridan Saint-Michel [mailto:webmaster@foxjet.com] > Sent: September 26, 2001 9:38 AM > To: Jason Dulberg; php-general@lists.php.net > Subject: Re: [PHP] select based on time/date > > > The reason my query didn't work is you have time_in as a varchar. > Change it to a datetime field or timestamp field and it should work. > > I would suggest making it a timestamp field. That way whenever > you update the row (probably update the session field with a new > session) MySQL will automatically set time_in to Now(). This will > avoid a lot of headache for you =) > > Sheridan Saint-Michel > Website Administrator > FoxJet, an ITW Company > www.foxjet.com > > > ----- Original Message ----- > From: "Jason Dulberg" <jdulberg@nas.net> > To: "Sheridan Saint-Michel" <webmaster@foxjet.com>; > <php-general@lists.php.net> > Sent: Tuesday, September 25, 2001 5:08 PM > Subject: RE: [PHP] select based on time/date > > > > I tried basically what you have but I got an error: > > > > $sql="select * from logged_in where time_in + interval 1 hour <= now()"; > > $result = mysql_query($sql); > > > > If it will help, here's the table structure -- looks like my > structure is > > bit different from what I orignally posted: > > > > CREATE TABLE logged_in ( > > id tinyint(4) DEFAULT '0' NOT NULL auto_increment, > > session varchar(100) DEFAULT '0' NOT NULL, > > time_in varchar(50) NOT NULL, > > KEY id (id) > > ); > > > > Thanks again. > > > > __________________ > > Jason Dulberg > > Extreme MTB > > http://extreme.nas.net

« previous php.general (#68901) next »