Jun 23rd, 2009, 5:32 PM
Heya,
Excellent! Glad it's working out so far.
To only display entries on the current day, you'll need to doctor the SQL to limit the results returned. Try this.
In your PHP, add these lines. They compute the current day in MySQL-friendly format and the FOLLOWING day.
In the example I listed above, try adding these lines before this line:
They only need to be called once, so they needn't be in the loop.
Lastly, edit the SQL query to include the date range. So change it to this:
And I think that's it! Unless I messed something up, that should return everything on the current day - regardless of the time the person visits the page.
Hope this helps!
- Ben
Excellent! Glad it's working out so far.
To only display entries on the current day, you'll need to doctor the SQL to limit the results returned. Try this.
In your PHP, add these lines. They compute the current day in MySQL-friendly format and the FOLLOWING day.
PHP Code:
list($year, $month, $day) = split(",", date("Y,m,d"));
$start_date = "$year-{$month}-{$day}";
$end_date = date("Y-m-d", mktime(0, 0, 0, $month, $day+1, $year));
In the example I listed above, try adding these lines before this line:
PHP Code:
foreach ($rooms as $room)
They only need to be called once, so they needn't be in the loop.
Lastly, edit the SQL query to include the date range. So change it to this:
PHP Code:
$query = mysql_query("
SELECT *
FROM {$g_table_prefix}form_{$form_id}
WHERE room = '$room' AND
submission_date > '$start_date' AND
submission_date < '$end_date'
");
And I think that's it! Unless I messed something up, that should return everything on the current day - regardless of the time the person visits the page.
Hope this helps!
- Ben