Jayden_Blade Posted March 12, 2014 Share Posted March 12, 2014 (edited) I am trying to check if it has been one month or longer sense some one signed up for my site. I am doing something wrong. I want it to post the persons username if they have been on the site one month or less. db sign up date is in Y,m,d format. I know $datecheck is a number like 951170532. $b comes out to be something like 2014-3-11. <?php error_reporting(E_ALL); $year = (date('Y')); $month = (date('m')-1); $day = date(('d')); //echo "$month, $day, $year"; $datecheck = mktime($year,$month,$day,0,0,0); include ('database.php'); $new = mysql_query("SELECT DISTINCT username, signupdate FROM profiledata"); $a = mysql_fetch_array($new); $b = $a['signupdate']; if($b>=$datecheck){ print "<ul>"; while($users=mysql_fetch_array($b)){ print "<li>{$users[0]}</li>"; } } ?> Edited March 12, 2014 by Jayden_Blade Quote Link to comment Share on other sites More sharing options...
Solution Zane Posted March 12, 2014 Solution Share Posted March 12, 2014 (edited) If you have the signup_date column set to a DATE type, then there's no reason to use PHP. SELECT id, signup_date FROM pdata WHERE signup_date >= DATE_SUB(NOW(), INTERVAL 30 DAY)That way, ONLY the users whose signup_date is a month old will be returned. Edited March 12, 2014 by Zane Quote Link to comment Share on other sites More sharing options...
Jayden_Blade Posted March 12, 2014 Author Share Posted March 12, 2014 Sweet. TY!! Quote Link to comment 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.