SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist
    Join Date
    Dec 2006
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Pagination link not showing

    Hi Guys,

    This is more than likely something really simple but when i load my pagination page the "Next" link isn't showing! if i tamper with the url like:

    admin.php?page=customer_management&page-no=2

    it shows the links for "Prev" fine and works as it should! it just doesn't show me the link on the first page to goto page 2

    code:

    PHP Code:
    <?php
      $page_number 
    $_GET['page-no'];
      
      if (
    intval($page_number) < 1)
      {
       
    $page_number 1;
      }
        
      
    $max 10
      
    $num $page_number $max $max;  
      
      
    // grab the customers //
      
    $q_customers "SELECT * FROM `fcp_customers`";
      
    $r_customers mysql_query($q_customers) or die (mysql_error());
      
    $a_customers mysql_num_rows($r_customers);
      
      
    // Pagination query
      
    $p_pagination "SELECT * FROM `fcp_customers` LIMIT $num$max";
      
    $r_pagination mysql_query($p_pagination) or die (mysql_error());
      
    $a_pagination mysql_num_rows($r_pagination);
      
      
    // start the table //
      
    print("<table width='95%' border='0' cellpadding='5' cellspacing='1' class='tbl_login' />\n");
      print(
    "<tr>\n");
      print(
    "<td align='center' class='c3'><b>ID</b></td><td align='center' class='c3'><b>First Name</b></td><td align='center' class='c3'><b>Last Name</b></td><td align='center' class='c3'><b>Registered</b></td><td align='center' class='c3'><b>Last Login</b></td><td align='center' class='c3'><b>Country</b></td><td align='center' class='c3'><b>Action</b></td>\n");
      print(
    "</tr>\n"); 
      print(
    "<tr class=\"c5\">\n");
      print(
    "<td align=\"left\"><img src=\"images/pixel.gif\" width=\"1\" height=\"1\"></td><td align=\"left\"><img src=\"images/pixel.gif\" width=\"1\" height=\"1\"></td><td align=\"left\"><img src=\"images/pixel.gif\" width=\"1\" height=\"1\"></td><td align=\"left\"><img src=\"images/pixel.gif\" width=\"1\" height=\"1\"></td><td align=\"left\"><img src=\"images/pixel.gif\" width=\"1\" height=\"1\"></td><td align=\"left\"><img src=\"images/pixel.gif\" width=\"1\" height=\"1\"></td><td align=\"left\"><img src=\"images/pixel.gif\" width=\"1\" height=\"1\"></td>\n");
      print(
    "</tr>\n");
      
      
    // while loop //
      
    while($row mysql_fetch_array($r_pagination))
      {
      
               
    $cus_id $row['id'];
            
    $cus_fname $row['first_name'];
            
    $cus_lname $row['last_name'];
          
    $cus_country $row['country'];
         
    $cus_reg_date $row['registered'];
       
    $cus_last_login $row['last_logged_in'];
       
       
    // format the date //
       
    $cus_reg_pretty        date("F j, Y, g:i a"strtotime($cus_reg_date)); 
       
    $cus_last_login_pretty date("F j, Y, g:i a"strtotime($cus_last_login)); 
       
       
    // include the coutry flags //
       
    include("inc/inc-flags.php");
       
      
    // alternate border color
      
    $row_color = ($row_color == "class=\"no_color\"") ? "class=\"c1\"" "class=\"no_color\"";
       
      print(
    "<tr $row_color><td class=\"font_for_forms\" align='left'>$cus_id</td><td class=\"font_for_forms\" align='left'>$cus_fname</td><td class=\"font_for_forms\" align='left'>$cus_lname</td><td class=\"font_for_forms\" align='left'>$cus_reg_pretty</td><td class=\"font_for_forms\" align='left'>$cus_last_login_pretty</td><td class=\"font_for_forms\" align='center'>$flag</td><td class=\"font_for_forms\" align='center'><a class='smart_links' href='admin.php?page=view_customers&customer_id=$cus_id'>View</a> | <a class='smart_links' href='admin.php?page=edit_customers&customer_id=$cus_id'>Edit</a> | <a class='smart_links' href='admin.php?page=delete_customer&customer_id=$cus_id'>Delete</a></td></tr>\n");
      
      }
     
      print(
    "</table>");
      
      
    $totalpage     ceil($a_pagination/$max) + 1;  
      
    $total_results ceil($a_pagination/$max);
      
      
    $prevlink = ($page_number 1);
      
    $nextlink = ($page_number 1);

      
    // styling //
      
    print("<br /><div id='container'>");
      
      
    // previous link //
      
    if($page_number 1) { 
            echo 
    "<a class=\"page_links\" href=\"admin.php?page=customer_management&page-no=$prevlink\">Prev</a></span>&nbsp;\n"
      } 
        
      for(
    $i 1$i $totalpage$i++)
      { 
        
        if (
    $i == $page_number
        { 
          echo 
    "<span class=\"page_links\">$i</span>&nbsp;\n"
        } else { 
          echo 
    "<a class=\"page_links\" href=\"admin.php?page=customer_management&page-no=$i\">$i</a></span>&nbsp;\n"
        } 
      } 

      if(
    $page_number $totalpage 1) { 
            echo 
    "<a class=\"page_links\" href=\"admin.php?page=customer_management&page-no=$nextlink\">Next</a></a>\n"
      }   
      
      print(
    "</div><br />");
    ?>
    i have went over it for days lol

    thanks guys

    Graham

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try this, by changing those lines:

    PHP Code:
    $totalpage     ceil($a_pagination/$max) + 1;   
    $total_results ceil($a_pagination/$max); 
    to

    PHP Code:
      $totalpage     ceil($a_customers/$max) + 1;   
      
    $total_results ceil($a_customers/$max); 
    let us know if it works

  3. #3
    SitePoint Evangelist
    Join Date
    Dec 2006
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Mate,

    sorry was away for a few days! that didnt seem to work either

    Graham

  4. #4
    SitePoint Zealot Dachande663's Avatar
    Join Date
    Feb 2005
    Location
    Birmingham, UK
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try changing:
    Code:
      if($page_number < $totalpage - 1) {
    to:
    Code:
      if($page_number < $totalpage) {
    Web Developer & Geek: hybridlogic.co.uk ~ lukelanchester.com


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •