Re: [PHP-DB] Log Application Formatting Issue...

2002-10-18 Thread Jason Wong
On Saturday 19 October 2002 00:09, NIPP, SCOTT V (SBCSI) wrote:
 I am trying to tweak an application that I have developed.  The
 application is our On-Call Log.  This application consists of three
 pages; one page to input new entries, one page to edit existing entries,
 and finally a log view page.  The log view page displays all entries for
 the past 5 days.  The display of the entries is formatted properly, and
 presented chronologically with the oldest first with 10 items per page.
 This is exactly what I want.  The one thing that I want to change is that
 the log defaults to displaying the first page containing the oldest
 items. I would like the log to display exactly as it does, but default to
 displaying the last page first.  This way we see the most recent items
 first.
   I hope this makes sense, and following is what I think are the
 relevant sections of the code:

One quick fix is to just display the items in reverse order so the newest 
items are always first ...

 { some code snipped }
 mysql_select_db($database, $Prod);
 $query_entry = SELECT * FROM oncall WHERE TO_DAYS(NOW()) - TO_DAYS(ptime)
 =5 ORDER BY 'ptime' ASC;

... change the ASC to DESC should do the trick.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *


/*
Yow!  Did something bad happen or am I in a drive-in movie??
*/


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] Log Application Formatting Issue...

2002-10-18 Thread NIPP, SCOTT V (SBCSI)
Yeah, this is the exact fix I am trying to avoid.  Thanks for the
feedback, but I prefer to keep the items chronological ascending order.  I
know there has to be a way to simply default the display to the last page of
the dataset.

-Original Message-
From: Jason Wong [mailto:phplist;gremlins.com.hk]
Sent: Friday, October 18, 2002 11:58 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Log Application Formatting Issue...


On Saturday 19 October 2002 00:09, NIPP, SCOTT V (SBCSI) wrote:
 I am trying to tweak an application that I have developed.  The
 application is our On-Call Log.  This application consists of three
 pages; one page to input new entries, one page to edit existing entries,
 and finally a log view page.  The log view page displays all entries for
 the past 5 days.  The display of the entries is formatted properly, and
 presented chronologically with the oldest first with 10 items per page.
 This is exactly what I want.  The one thing that I want to change is that
 the log defaults to displaying the first page containing the oldest
 items. I would like the log to display exactly as it does, but default to
 displaying the last page first.  This way we see the most recent items
 first.
   I hope this makes sense, and following is what I think are the
 relevant sections of the code:

One quick fix is to just display the items in reverse order so the newest 
items are always first ...

 { some code snipped }
 mysql_select_db($database, $Prod);
 $query_entry = SELECT * FROM oncall WHERE TO_DAYS(NOW()) - TO_DAYS(ptime)
 =5 ORDER BY 'ptime' ASC;

... change the ASC to DESC should do the trick.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *


/*
Yow!  Did something bad happen or am I in a drive-in movie??
*/


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Log Application Formatting Issue...

2002-10-18 Thread Paul Burney
on 10/18/02 1:03 PM, NIPP, SCOTT V (SBCSI) at [EMAIL PROTECTED] appended the
following bits to my mbox:

 Yeah, this is the exact fix I am trying to avoid.  Thanks for the
 feedback, but I prefer to keep the items chronological ascending order.  I
 know there has to be a way to simply default the display to the last page of
 the dataset.

I can think of a few other ways, none perfect:

1) Perform the same query as now, then use mysql_data_seek to start at 10
rows from the end.  Something like:

mysql_data_seek($result, mysql_num_rows($result) - 10);

The next 10 calls to mysql_fetch_* will give you the rows you want. (for
$I=0; $I  10; $I++) The next page you do the same with 20, etc.

2) Similar thing, but first get the number of rows for the query, either the
same one or a SELECT COUNT(*) query, then use MySQL limit to limit to the 10
rows from the end.

3) Change to DESC as suggested by someone else, but instead of directly
outputting the result, store it into another array.  Then reverse that array
in php and display it.

HTH.

Sincerely,

Paul Burney
http://paulburney.com/

?php
while ($self != asleep) {
$sheep_count++;
}
?



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php