It is not that hard to create paging with mysql/mysql
Here is the logic:
Imagine you have 50 results and you want to break down into 5 pages with 10 results each. So the script should receive a GET variable like
page=5 in order to display results. Also the mysql query should be limited pagewise with
LIMIT START,OFFSET
i am posting the script here. Note that it is a home made script and may not work exactly. i am posting this to illustrate the simple logic behind posting.
Quote:
// Find the total listings
$rs_total_listings = mysql_query("select *
from listings
where approved = 1
", $link)
or die("Couldn't execute query".mysql_error());
// Paging & Alphabetical properties//
$limit = 15; //pages limit
if (!isset($_GET['page']) )
{ $start=0;
$show_paging = "limit $start,$limit";
} else
{
$start = ($_GET['page'] - 1) * $limit;
$show_paging = "limit $start,$limit"; }
$total_listings = mysql_num_rows($rs_total_listings);
$total_pages = ceil($total_listings/$limit);
$rs_listings = mysql_query("select `title`,`desc`,`url`
from listings
where did = '$did' and approved = 1
$show_alphabetical
order by paid desc, added desc
$show_paging
", $link)
or die("Couldn't execute query".mysql_error());
// outputting the pages
if ($total_listings > $limit)
{
echo "<h4>Pages: ";
$i = 0;
while ($i < $total_pages)
{
$page_no = $i+1;
echo "<a href=\"$page_no\">$page_no</a> ";
$i++;
}
echo "</h4>";
}
|
If i remember correctly there are also good php classes available to generate different varieties of paging with mysql results.
EZPaging:
http://www.best-php-scripts.com/details460.htm