[PHP-DB] Log Application Formatting Issue...
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: { 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; $query_limit_entry = sprintf(%s LIMIT %d, %d, $query_entry, $startRow_entry, $maxRows_entry); $entry = mysql_query($query_limit_entry, $Prod) or die(mysql_error()); $row_entry = mysql_fetch_assoc($entry); if (isset($HTTP_GET_VARS['totalRows_entry'])) { $totalRows_entry = $HTTP_GET_VARS['totalRows_entry']; } else { $all_entry = mysql_query($query_entry); $totalRows_entry = mysql_num_rows($all_entry); } $totalPages_entry = ceil($totalRows_entry/$maxRows_entry)-1; { Not completely sure what following section does. } $queryString_entry = ; if (!empty($HTTP_SERVER_VARS['QUERY_STRING'])) { $params = explode(, $HTTP_SERVER_VARS['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { if (stristr($param, pageNum_entry) == false stristr($param, totalRows_entry) == false) { array_push($newParams, $param); } } if (count($newParams) != 0) { $queryString_entry = . implode(, $newParams); } } $queryString_entry = sprintf(totalRows_entry=%d%s, $totalRows_entry, $queryString_entry); ? { I know that this has to do with handling the log page numbering, but fuzzy on the details. } { some html formatting snipped } ?php do { if ($row_entry['P1']) { ? tr td height=23 bgcolor=#FAADBC div align=centera href=oncall_update.php?callid=?php echo $row_entry['callid']; ??php echo $row_entry['callid']; ?/a/div/td td valign=top bgcolor=#FAADBC?php echo $row_entry['sa']; ?/td td valign=top bgcolor=#FAADBC?php echo $row_entry['ptime']; ?/td td valign=top bgcolor=#FAADBCdiv align=center?php echo $row_entry['system']; ?/div/td td valign=top bgcolor=#FAADBC?php echo $row_entry['name']; ?/td td valign=top bgcolor=#FAADBC?php echo $row_entry['problem']; ?/td td valign=top bgcolor=#FAADBC?php echo $row_entry['resolution']; ?/td /tr ?php } else { ? tr td height=23 bgcolor=#CC div align=centera href=oncall_update.php?callid=?php echo $row_entry['callid']; ??php echo $row_entry['callid']; ?/a/div/td td valign=top bgcolor=#CC?php echo $row_entry['sa']; ?/td td valign=top bgcolor=#CC?php echo $row_entry['ptime']; ?/td td valign=top bgcolor=#CCdiv align=center?php echo $row_entry['system']; ?/div/td td valign=top bgcolor=#CC?php echo $row_entry['name']; ?/td td valign=top bgcolor=#CC?php echo $row_entry['problem']; ?/td td valign=top bgcolor=#CC?php echo $row_entry['resolution']; ?/td /tr ?php } ? { Snipped the rest } I am using DreamWeaver MX, so some of this code may be a little strange. This is also the reason why I am a bit confused by some of what is goign on in the page. Thanks in advance for the help. Scott Nipp Phone: (214) 858-1289 E-mail: [EMAIL PROTECTED] Web: http:\\ldsa.sbcld.sbc.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
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
RE: [PHP-DB] Log Application Formatting Issue...
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...
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