Jump to content

Pagination placement question


graham23s

Recommended Posts

Hi Guys,

 

i have a small problem with this pagination script i have added, i put the number of results to be displayed to 1, which leaves 4 pages to look at (4 entries in the database) but it displays all the rows, can anyone see what i have done wrong:

 

<?php
     #########################################################################################################
     if (isset($_GET['pageno'])) {
     
       $pageno = $_GET['pageno'];
       
       } else {
       
       $pageno = 1;
    
       } // if
       
       $query6 = "SELECT count(*) FROM `TEST`";
       $result6 = mysql_query($query6) or die (mysql_error());
       $query_data = mysql_fetch_row($result6);
       $numrows = $query_data[0];

       $rows_per_page = 1;
       $lastpage = ceil($numrows/$rows_per_page);
       
       $pageno = (int)$pageno;
       if ($pageno < 1) {
       $pageno = 1;
       } elseif ($pageno > $lastpage) {
       $pageno = $lastpage;
       } // if

       $limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page;
       
       $query = "SELECT * FROM `TEST` $limit";
       $result = mysql_query($query) or die (mysql_error());
       
       // Place info here.../////////////////////////////////////////////////////////////
       
            // start the table...///////////////////////////////////////////////////////////////
     echo '<br /><h4>TEST</h3>
           <table width="600" border="1" bordercolor="#000000" cellspacing="0" cellpadding="2" />
           <tr>
           <th>TEST</th><th>TEST</th><th>TEST</th><th>TEST</th><th>TEST</th>
           </tr>
           <tr>';

      // get the latest nzbs...///////////////////////////////////////////////////////////
     $query1 = "SELECT * FROM `TEST`";
     $result1 = mysql_query($query1) or die (mysql_error());
               
     // loop the results out...//////////////////////////////////////////////////////////
     while ($row = mysql_fetch_array($result1)) {
     
     $id = $row['id'];
     $category = $row['category'];
     $added = $row['date_added'];
     $poster_name = $row['poster_name'];
     
     // get the users name clickable.../////////////////////////////////////////////////
     $query2 = "SELECT * FROM `TEST` WHERE `username`='$poster_name'";
     $result2 = mysql_query($query2) or die (mysql_error());
     $rows = mysql_fetch_array($result2) or die (mysql_error());
     
     // the id and username...///////////////////////////////////////////////////////////
     $user_id = $rows['id'];
     $username = $rows['username'];
     
     $query3 = "SELECT * FROM `comments` WHERE `id`='$id'";
     $result3 = mysql_query($query3) or die (mysql_error());
     
     $num_comments = mysql_num_rows($result3);
     

          
     }
                      
     echo '</table><br />';
       
       // Place info here.../////////////////////////////////////////////////////////////      

       if ($pageno == 1) {
       echo " FIRST PREV ";
       } else {
       echo " <a href='{$_SERVER['PHP_SELF']}?pageno=1'>FIRST</a> ";
       $prevpage = $pageno-1;
       echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$prevpage'>PREV</a> ";
       } // if
       echo " ( Page $pageno of $lastpage ) ";
       
       if ($pageno == $lastpage) {
       echo " NEXT LAST ";
        } else {
       $nextpage = $pageno+1;
       echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage'>NEXT</a> ";
       echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$lastpage'>LAST</a> ";
       echo "<br /><br />";
       } // if      
?>

 

Thanks for any help guys

 

Graham

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.