brown2005 Posted March 12, 2008 Share Posted March 12, 2008 $x = "30"; $sql = "SELECT COUNT(*) AS members_count FROM members WHERE ( code here )"; now where code here is.. i want to select all members who have logged in in $x days with members_login being the field with the date... thanks in advance Link to comment https://forums.phpfreaks.com/topic/95825-members-in-x-days/ Share on other sites More sharing options...
pocobueno1388 Posted March 12, 2008 Share Posted March 12, 2008 <?php $x = "30"; $sql = "SELECT COUNT(*) AS members_count FROM members WHERE members_login < (NOW() - INTERVAL $x DAY)"; ?> Link to comment https://forums.phpfreaks.com/topic/95825-members-in-x-days/#findComment-490565 Share on other sites More sharing options...
brown2005 Posted March 12, 2008 Author Share Posted March 12, 2008 hi thanks for the help, but that returns a 0 count Link to comment https://forums.phpfreaks.com/topic/95825-members-in-x-days/#findComment-490572 Share on other sites More sharing options...
brown2005 Posted March 12, 2008 Author Share Posted March 12, 2008 1 2008-03-12 17:22:43 2 2008-03-12 17:22:43 3 2008-02-11 17:22:43 i have the above 3 results in my table.. and it comes up with 1.. which is number 3... which is out of 30 days. the code above looks like it gives all members that have logged in before $x amount of days.. but i want from $x days to now.... any ideas would be much appreciated.. thanks in advance. Link to comment https://forums.phpfreaks.com/topic/95825-members-in-x-days/#findComment-490618 Share on other sites More sharing options...
pocobueno1388 Posted March 12, 2008 Share Posted March 12, 2008 Try changing the query to: SELECT COUNT(*) AS members_count FROM members WHERE members_login <= (NOW() - INTERVAL $x DAY) Link to comment https://forums.phpfreaks.com/topic/95825-members-in-x-days/#findComment-490634 Share on other sites More sharing options...
brown2005 Posted March 12, 2008 Author Share Posted March 12, 2008 nope still 1... wat does <= (NOW() - INTERVAL $x DAY) actually mean? Link to comment https://forums.phpfreaks.com/topic/95825-members-in-x-days/#findComment-490794 Share on other sites More sharing options...
pocobueno1388 Posted March 12, 2008 Share Posted March 12, 2008 This part: members_login <= (NOW() - INTERVAL $x DAY) means If the date members_login is less than or equal to x days ago. I think I got the symbol messed up and turned the wrong way So change it to this: SELECT COUNT(*) AS members_count FROM members WHERE members_login >= (NOW() - INTERVAL $x DAY) Link to comment https://forums.phpfreaks.com/topic/95825-members-in-x-days/#findComment-490801 Share on other sites More sharing options...
brown2005 Posted March 12, 2008 Author Share Posted March 12, 2008 yes that works.. why on earth did i not spot that..... tut tut.. anyway thanks very much Link to comment https://forums.phpfreaks.com/topic/95825-members-in-x-days/#findComment-490808 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.