I have a Log Application that is fully functional, but I need to change a behavior and can't quite figure out how. This app has three pages, one for entering new entries, one to display all entries for the last 5 days, and the final page allows updating of existing entries. The problem I am having is that the log display page displays the data ordered by date and displays the oldest data first. I want the data ordered this way, but I would like it to default to the last page such that you see the most recent entry first. The log displays 10 entries per page, and I just want it to default to displaying the last page rather than the first. Below is what I think are the pertinent sections of code. Please let me know what you think, and if you need more information or code. Thanks in advance for the assistance.
<?php require_once('prod.lib.php'); ?> <?php $currentPage = $HTTP_SERVER_VARS["PHP_SELF"]; $maxRows_entry = 10; $pageNum_entry = 0; if (isset($HTTP_GET_VARS['pageNum_entry'])) { $pageNum_entry = $HTTP_GET_VARS['pageNum_entry']; } $startRow_entry = $pageNum_entry * $maxRows_entry; 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; $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); ?> ... A bunch of HTML formatting snipped out... <?php } while ($row_entry = mysql_fetch_assoc($entry)); ?> </table>Records <?php echo ($startRow_entry + 1) ?> to <?php echo min($startRow_entry + $maxRows_entry, $totalRows_entry) ?> of <?php echo $totalRows_entry ?> <table border="0" width="50%" align="center"> <tr> <td width="23%" align="center"> <?php if ($pageNum_entry > 0) { // Show if not first page ?> <a href="<?php printf("%s?pageNum_entry=%d%s", $currentPage, 0, $queryString_entry); ?>">First</a> <?php } // Show if not first page ?> </td> <td width="31%" align="center"> <?php if ($pageNum_entry > 0) { // Show if not first page ?> <a href="<?php printf("%s?pageNum_entry=%d%s", $currentPage, max(0, $pageNum_entry - 1), $queryString_entry); ?>">Previous</a> <?php } // Show if not first page ?> </td> <td width="23%" align="center"> <?php if ($pageNum_entry < $totalPages_entry) { // Show if not last page ?> <a href="<?php printf("%s?pageNum_entry=%d%s", $currentPage, min($totalPages_entry, $pageNum_entry + 1), $queryString_entry); ?>">Next</a> <?php } // Show if not last page ?> </td> <td width="23%" align="center"> <?php if ($pageNum_entry < $totalPages_entry) { // Show if not last page ?> <a href="<?php printf("%s?pageNum_entry=%d%s", $currentPage, $totalPages_entry, $queryString_entry); ?>">Last</a> <?php } // Show if not last page ?> </td> </tr> </table> ...Cut of the rest of the HTML junk... 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