query results incomplete
Posted: Tue May 04, 2010 7:31 pm
Hello,
I have a web page with a link that uses Php/MySQL to return posted comments between specific dates, but the results returned always lack the most recent post if ORDER BY DESC or the very first post if ORDER BY ASC. As my programming skills are wanting, I thought perhaps someone here might point out my error(s). Here is the code...
I am using WAMP Server 2 (Php 5.3, MySQL 5.1.36 on Windows 7)
Thanks for any help...
ggoose
I have a web page with a link that uses Php/MySQL to return posted comments between specific dates, but the results returned always lack the most recent post if ORDER BY DESC or the very first post if ORDER BY ASC. As my programming skills are wanting, I thought perhaps someone here might point out my error(s). Here is the code...
Code: Select all
<?php
$getdata = mysql_query("SELECT * FROM djm_req WHERE time_stamp BETWEEN '2010-05-01 00:00:00' AND '2010-05-31 23:59:59' ORDER BY entryID DESC") OR DIE;
IF (mysql_fetch_array($getdata) == 0) { //If there are no requests posted with the given time, echo:
echo "<p class='center' style='text-align: center;'>No Requests Posted</p>";
} ELSE {
WHILE ($getdata2 = mysql_fetch_array($getdata)) {
$getdata2['salut'] = strip_tags($getdata2['salut']); //Removes all HTML and Php tags from salut...
$getdata2['request'] = strip_tags($getdata2['request']); //Removes all HTML and Php tags from request...
$salut = $getdata2['salut'];
$request = $getdata2['request'];
$timestamp = strtotime($getdata2['time_stamp']);
$localtime = ($timestamp - 10800); //This is -3 hrs to make up timezone difference from west coast local time to east coast server time.
$date = date("l, F dS, Y @ g:i a", $localtime);
//Print out the resuslts for each posting
echo "<div style='width: 95%; border: 1px solid gray; padding: 10px 10px 0 10px; margin: 5px 0; text-align: left;'>";
echo "<h3>" .$salut. ",</h3>";
echo "<p class='center'>" .nl2br($getdata2['request']). "</p>";
echo "<p style='font-size: 9pt; font-style: italic;'>Posted: " .$date. "</p>";
echo "</div>";
}
}
?>Thanks for any help...
ggoose