In article <[EMAIL PROTECTED]>, 
>       Hey guys.  Thanks in advance for all the help that this group has
> provided to me so far.  I am still learning, so many of my questions have
> been pretty simple.  This may also be pretty simple, but I cannot for the
> life of me figure out how to make this happen.
>       I have a Log application that is running on Apache/PHP/MySQL.  This
> application has three pages: first a page to input new log entries, second a
> log view of entries, and the third is a page to edit existing entries.  The
> basics of all three pages is working great.  Upon entering a new record the
> app transfers you directly to the Log view page(s).  The Log view page(s)
> display 10 entries per page for the past 5 days chronologically beginning
> with the oldest.  Here is basically where my problem lies...  I want this
> exact behavior, only I want the view to default to the last page rather than
> the first.  I cannot figure out how to make this happen, and haven't had
> much luck in finding some code to borrow this from.  Here is the code
> section that handles the Log display:

<SNIP code>

$query_entry = "SELECT * FROM oncall WHERE TO_DAYS(NOW()) - TO_DAYS(ptime)
<=5 ORDER BY 'ptime' ASC";
$query_limit_entry = sprintf("%s LIMIT %d, %d", query_entry, 
$startRow_entry, $maxRows_entry);

This might be a bit simplistic, but why not do your query ordered in 
descending order? That will show the entries in reverse chronological 
order, with the most recent first.

If that is not acceptable, you might need to do a count of the number of 
rows extracted, then calculate from that count the LIMIT statement 
required to show the last series of entries.

David Robley
Temporary Kiwi!

Quod subigo farinam

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to