My first page shows fine the 15 results as requested and the links build up properly with the correct amounts at the bottom of the screen such as next, last etc.
But when I choose next the next page doesn't have any results, this is in a large form and I don't think that the values are getting passed to the next page, can't seem to pass the values as there are about 20 to be passed to the next page.

Any ideas please?

$sorter1 = "SELECT * FROM directory WHERE authorised = 'Y'";
$sorterResults1 = mysql_query($sorter1);
while ($sorterRow1 = mysql_fetch_array ($sorterResults1)){
$totalcount1++;
}
}
if (isset($_GET['pageno'])) {
 $pageno = $_GET['pageno'];
} else {
 $pageno = 1;
}
$rows_per_page = 15;
$lastpage      = ceil($totalcount1/$rows_per_page);
$pageno = (int)$pageno;
if ($pageno < 1) {
 $pageno = 1;
} elseif ($pageno > $lastpage) {
   $pageno = $lastpage;
}

$limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page;

NEXT SELECT Statement here SELECT $limit

And here's how I show the results:

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

    You could try putting

    print $sorter1;

    below your $sorter1 code and see if you're getting an empty string.
    I had a similar problem with some search engine code and had to place

    $searchwords = mysql_escape_string($_GET['words']);

    at the top of my page to fill in that empty string.

    That might help.

      Thanks for that I have put all my search criteria into that now thank you, as I click on next for the next page all the correct data is stored and shown correctly in the address bar.
      But the next lot of results are not showing, it seems as the data is not being submitted by the form again for the next page, it says enter some data which only shows when no data has been submitted.

        I noticed there's no counting code in your code. I don't remember the specifics of this, but in a nutshell this code is supposed to count out the results from a selected area and that helps with page links or something to that effect. Adding a count code might help with your problem. Try this, you'll need to edit it to match your code:

        // Count the number of records
            $query = "SELECT COUNT(*) FROM your table WHERE your column ORDER BY table's primary key";   
        $result = @mysql_query ($query); $row = mysql_fetch_array ($result, MYSQL_NUM); $num_records = $row[0];

          Yeah thanks, I do have that further up the page in my code, thanks for the advice though.

          I think my problem is that the form isn't submitting again when the new page loads, not too sure though. It seems to me that the submit button needs to be clicked when the "NEXT", "PREV" etc. buttons are clicked, not sure if this can be done.

            Write a Reply...