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. 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? 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 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 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? 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 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. 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 Link to comment https://forums.phpfreaks.com/topic/194478-logged-in-users/#findComment-1022940 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.