hi,
i have a simple solutions for paging a large query result into pages.
format your SQL Query like this and it will work
 
$nTotal_No_Of_Results_Shown_On_A_Page=20;
 
if (empty($nCurrentPage))
    $nCurrentPage=1;
 
$tablename="tblusers"; // table from where the data is comming from
$fieldtosorton="user_name"; //    a field on wich you want to sort the result returned
$where="user_enabled=1";        // any where clause
 
$strQuery="SELECT TOP ".$nTotal_No_Of_Results_Shown_On_A_Page." * FROM $tablename WHERE $fieldtosorton NOT IN (SELECT TOP " .($nTotal_No_Of_Results_Shown_On_A_Page * ($nCurrentPage -1)) ." ".$fieldtosorton." FROM ".$tablename." WHERE $where ORDER BY ".$fieldtosorton.") ".$where." ORDER BY ".$fieldtosorton;
 
this query will give you just the result that you want to show on the current page. all you have to do is maintain $nCurrentPage. if you change the query slightly you can get the total no of records and when you get total no of records then you can also get total no of pages.
 
HTH,
Haseeb
 
 
-------Original Message-------
 
Date: Saturday, August 23, 2003 01:00:49 PM
Subject: Re: [PHP] google style paginating
 
On Thu, 21 Aug 2003, Ted Conn wrote:
 
> Hi I am new to this newsgroup and I plan on replying to all the posts I can
> for now... but Id like to start out by asking a question. I am trying to
> paginate my sql results in 10 by 10, which I have been able to do no
> problem. but what I want to do is have the pages layed out in google style
> with (1)(2)(3)(4) etc etc and each one is clickeable that will take you to
> that page. I'll show you the code I am using now for next and back
> buttons...
>
 
  You might want to check Page and Pager_Sliding classes in PEAR:
 
 
--
 
 
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
 
____________________________________________________
  IncrediMail - Email has finally evolved - Click Here

Reply via email to