On Thu, Mar 20, 2008 at 7:35 AM, George J <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> I'm trying to resolve an issue with a pagination routine. Sounds like
> we're
> working on a similar routine. I have a query returning products from a
> database and then display the results in a defined number of products per
> page.
>
> Checkout - 'Newbie question, Which way is best?' in this newsgroup.
>
> George
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> i have spent some time to figure it out last time. i did create a simple
function to do it
total - is the total record. can be output of SELECT COUNT(*) FROM table
offset - is the current offset.
//display pages
function pages($total, $offset, $perpage)
{
if($total == 0) return;
$total_pages = floor($total / $perpage);
$current_page = floor($offset / $perpage);
$pg = '';
for($i = 0; $i <= $total_pages; $i++)
{
$pg .= "<a class='page_nav' href='?p=".($i *
$perpage)."'>".($i + 1)."</a>";
}
return $pg;
}
i am afraid this one look too simple. but you can see how the basis work.
this one simply print 1, 2, 3 etc..