PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 12th, 2005, 07:57 AM
unregistered unregistered is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 2 unregistered User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 5 sec
Reputation Power: 0
paging problem

Hey Guys,
I am using the following class for paging my results:

PHP Code:
function page_break($numrows$offset$limit) {
$multi "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" width=\"80%\" id=\"AutoNumber14\"><tr>";
    
$pages=intval($numrows/$limit);
 
    
$extra $_SERVER["QUERY_STRING"];
$extra explode("&"$extra);
for(
$i 0$i count($extra); $i++) {
    if(
$extra[$i]) {
     if(!
strstr($extra[$i],"offset=")) {
     
$current .= $extra[$i]. "&";
     }
}
}
 
    if (
$numrows%$limit) {
    
$pages++;
    }
 
$do $offset+2;
    
$increase1 1;
    
$increase2 $limit;
    if (
$do $numrows) {
     
$increase1 1;
     
$increase2 1;
    }
 
    if (
$offset >= 1) {
    
$prevoffset $offset $limit;
    
$prev .= "<td width=\"12%\"><a href=\"$PHP_SELF?$current\"><img border=\"0\" src=\"images/01.gif\" width=\"22\" height=\"24\"></a></td>
        <td width=\"12%\"><a href=\"$PHP_SELF?$current&offset=$prevoffset\"><img border=\"0\" src=\"images/01a.gif\" width=\"22\" height=\"24\"></a></td>\n"
;
    }
 
    if (! ( (
$offset/$limit) == ($pages 1) ) && ($pages 1) ) {
    
$newoffset $offset+$limit;
    
$next .= "<td width=\"12%\"><a href=\"$PHP_SELF?$current&offset=$newoffset\"><img border=\"0\" src=\"images/02a.gif\" width=\"22\" height=\"24\"></a>";
$not_last 1;
    }
    
$multi .= $prev;
$multi .= "<td width=\"60%\" class=\"sml\"><p align=\"center\"><b><font color=\"#FF6600\">";
    for (
$i 1$i <= $pages$i++) {
    
$newoffset $limit*($i-1);
    if (
$newoffset == $offset) {
    
$multi .= "[$i]&nbsp;\n";
    } else {
    
$multi .= "<a href=\"$PHP_SELF?$current&offset=$newoffset\">$i</a>&nbsp;\n";
    }
    }
$multi .= "</td>";
$multi .= $next;
$multi .= "<td width=\"15%\"><a href=\"$PHP_SELF?$current&offset=$newoffset\"><img border=\"0\" src=\"images/02.gif\" width=\"22\" height=\"24\"></a></td>";
$multi .= "</tr></table>";
    return 
$multi;



Now, the above works fine. However, the problem is, there are times when there are more than 1,000 results. This causes over 100 page links to be created. How do i limit only 10 pages to be listed at a time?

Something like this:

<< < 4 5 6 7 8 9 10 11 12 13 14 > >>


Thank you
unregistered.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > paging problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT