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:

<?php require_once('prod.lib.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 O
RDER BY 'ptime' ASC";
$query_limit_entry = sprintf("%s LIMIT %d, %d", $query_entry,
$startRow_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 = "";
  $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,

        Some HTML formatting omitted...

<?php do {
    <td height="23" bgcolor="#CCCCCC">
      <div align="center"><a href="oncall_update.php?callid=<?php echo
y['callid']; ?>"><?php echo $row_entry['callid']; ?></a></div></td>
    <td valign="top" bgcolor="#CCCCCC"><?php echo $row_entry['sa']; ?></td>
    <td valign="top" bgcolor="#CCCCCC"><?php echo $row_entry['ptime'];
    <td valign="top" bgcolor="#CCCCCC"><div align="center"><?php echo
['system']; ?></div></td>
    <td valign="top" bgcolor="#CCCCCC"><?php echo $row_entry['name'];
    <td valign="top" bgcolor="#CCCCCC"><?php echo $row_entry['problem'];
    <td valign="top" bgcolor="#CCCCCC"><?php echo $row_entry['resolution'];
  <?php } while ($row_entry = mysql_fetch_assoc($entry)); ?>

        thanks in advance for any assistance.

Scott Nipp
Phone:  (214) 858-1289
Web:  http:\\ldsa.sbcld.sbc.com

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

Reply via email to