xwishmasterx Posted April 18, 2011 Share Posted April 18, 2011 Hello I am trying to only display results within the time period last sunday too next sunday. my code: <?php $today = date('Y-m-d H:i:s'); $time = strtotime($today); $last_sunday = strtotime('last sunday', $time); $next_sunday = strtotime('next sunday', $time); $format = 'Y-m-d H:i:s'; $last_sunday = date($format, $last_sunday); $next_sunday = date($format, $next_sunday); ?> <?php $sql_totalsurfs = ("SELECT vtp_members.id, vtp_members.name, vtp_members.teamleader, vtp_tracking.Timber, vtp_tracking.Stone, vtp_tracking.Marble, teams.team_name, count(vtp_tracking.id) surfs FROM vtp_members, vtp_tracking, teams WHERE vtp_members.team_id=".$_GET['t']." AND vtp_tracking.credit_members_id=vtp_members.id AND vtp_tracking.action_date>'$last_sunday' AND vtp_tracking.action_date<'$next_sunday' GROUP BY vtp_members.id ORDER BY surfs DESC LIMIT 0, 10"); $rstotalsurfs = mysql_query($sql_totalsurfs); $numrows = mysql_num_rows($rstotalsurfs); ....... Is there and error somwhere in the code? Quote Link to comment https://forums.phpfreaks.com/topic/234098-time-related-issue-error-in-the-code/ Share on other sites More sharing options...
maxudaskin Posted April 18, 2011 Share Posted April 18, 2011 Are you getting any erroneous result from PHP or MySQL? If so, please provide the errors. Quote Link to comment https://forums.phpfreaks.com/topic/234098-time-related-issue-error-in-the-code/#findComment-1203212 Share on other sites More sharing options...
xwishmasterx Posted April 18, 2011 Author Share Posted April 18, 2011 Not getting any errors. Problem is it seems it gets all results from the table not "paying attention" to the timeframe. Quote Link to comment https://forums.phpfreaks.com/topic/234098-time-related-issue-error-in-the-code/#findComment-1203219 Share on other sites More sharing options...
Pikachu2000 Posted April 18, 2011 Share Posted April 18, 2011 Echo your query to make sure it contains the values you'd expect it to contain, and if it does, paste it into phpMyAdmin and see what results you get. Quote Link to comment https://forums.phpfreaks.com/topic/234098-time-related-issue-error-in-the-code/#findComment-1203241 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.