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
 
____________________________________________________
  IncrediMail - Email has finally evolved - Click Here

Reply via email to