vividona Posted March 8, 2010 Share Posted March 8, 2010 I need to select users who logged in during 24 hours $time = time() - (60*60*24); $chkusers = $SiteDatabase->dbqueries("SELECT `uid`, `username`, `lastaccess` FROM " . ArticleSystem::BHL_DB_PREFIX . "" . ArticleSystem::BHL_DB_USER_TBL . " WHERE `lastaccess` < '$time' ORDER BY `lastaccess` DESC"); my code count wrong time. Quote Link to comment https://forums.phpfreaks.com/topic/194478-logged-in-users/ Share on other sites More sharing options...
Adam Posted March 8, 2010 Share Posted March 8, 2010 What data type is the "lastaccess" field? Quote Link to comment https://forums.phpfreaks.com/topic/194478-logged-in-users/#findComment-1022917 Share on other sites More sharing options...
vividona Posted March 8, 2010 Author Share Posted March 8, 2010 I inserted into it php time() function like this 1268019084 Quote Link to comment https://forums.phpfreaks.com/topic/194478-logged-in-users/#findComment-1022919 Share on other sites More sharing options...
vividona Posted March 8, 2010 Author Share Posted March 8, 2010 It is working now according to my code but it select users after 24 hours I need during 24 hours not after Quote Link to comment https://forums.phpfreaks.com/topic/194478-logged-in-users/#findComment-1022921 Share on other sites More sharing options...
trq Posted March 8, 2010 Share Posted March 8, 2010 Again.... What data type is the "lastaccess" field? Quote Link to comment https://forums.phpfreaks.com/topic/194478-logged-in-users/#findComment-1022929 Share on other sites More sharing options...
vividona Posted March 8, 2010 Author Share Posted March 8, 2010 varchar Quote Link to comment https://forums.phpfreaks.com/topic/194478-logged-in-users/#findComment-1022931 Share on other sites More sharing options...
trq Posted March 8, 2010 Share Posted March 8, 2010 So, how do you expect a database to sort a string based on time? lastaccess needs to be a timestamp. Quote Link to comment https://forums.phpfreaks.com/topic/194478-logged-in-users/#findComment-1022935 Share on other sites More sharing options...
vividona Posted March 8, 2010 Author Share Posted March 8, 2010 I resolved it like this $time = time(); $time2 = time() - (60*60*24); $CheckArtisList = $SiteDatabase->dbqueries("SELECT `uid`, `username`, `lastaccess` FROM " . ArticleSystem::BHL_DB_PREFIX . "" . ArticleSystem::BHL_DB_USER_TBL . " WHERE `lastaccess` > '$time2' AND `lastaccess` < '$time' ORDER BY `lastaccess` DESC"); thank you guys Quote Link to comment https://forums.phpfreaks.com/topic/194478-logged-in-users/#findComment-1022940 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.