Bluehost.com Web Hosting $6.95

Results Page Numbering

This is a discussion on Results Page Numbering within the PHP General forums, part of the PHP Programming Forums category; hi, i have a simple solutions for paging a large query result into pages. format your SQL Query like this ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-23-2003
Haseeb
 
Posts: n/a
Default Results Page Numbering

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

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 01:48 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0