PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 30th, 2000, 07:50 PM
CS CS is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Posts: 44 CS User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
I have a table that currently holds over 1500 entries.

When I select * from the table it always takes forever to load, so I set my site up to display 50 items per page. I can search through items 50 at a time forwards or backwards with no problem.

But, now lets say I want to be able to skip the first 500 entries (10 pages). How do I set up dynamic pages so I can go straight to page 10 instead of having to press the "next" link 10 times? Thanks for any help.

Reply With Quote
  #2  
Old May 30th, 2000, 09:19 PM
weddeh weddeh is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 7 weddeh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to weddeh
In order to display in spesific item per page you need to rely on the database system to get maximize performance,
example: in MySQL you do it by adding limit keyword in your sql syntax...

SELECT * FROM Member ORDER BY MemberName
LIMIT 0, 50

it will select the first record until the next 50 records, if you want to skip the first 500 entries you can do it by

SELECT * FROM Member ORDER BY MemberName
LIMIT 500, 50


Tata

Reply With Quote
  #3  
Old May 30th, 2000, 09:29 PM
CS CS is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Posts: 44 CS User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
hmmm...

ok. (tries to hide ignorance) How would I post that on a page?

Like at the bottom of page one I want to have little page number links

2 3 4 5... etc.

That way when I'm on page 1, I can skip to page 5.... ya know like bulletin boards do.

Would I just make each link a select statement? How could I do that dynamically so I don't have to add another 10 pages after another 500 entries? Am I making any sense (because sometimes I feel like I talk incircles)? Thanks for any help.

Reply With Quote
  #4  
Old May 31st, 2000, 08:17 PM
CS CS is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Posts: 44 CS User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
My friend helped me figure it out. The code is below for those in need of something similar.

<?
//initializing variable for 50-item display..
$i = 1;
$count=1;
if (isset($pages))
{$pagecount = 50 *($pages -1);
}else{
$pagecount=0;}

$result= mysql_query ("SELECT * FROM table order by ID desc");

//initializing loop to skip over already viewed items
$startpoint=0;
while ($startpoint != $pagecount && $row = mysql_fetch_array($result)){
$startpoint++; }


//initializing loop to show next 50 items...
$currentcount=1;
while ($currentcount<=50 && $row = mysql_fetch_array($result))
{
print $row["active"];
$currentcount++;
}
//adding clauses for 1,2,3... links, allowing the number of already viewed items to carry over

$tracker = mysql_query ("SELECT * FROM table order by ID desc");

while ($row = mysql_fetch_array($tracker)){
$count++; }

$pages= $count/20;
if ($count % 20 !=0) {
$pages++;}

while ($i <= $pages)
{
print('<a href="page.phtml?pages=');
print($i);
print('">');
print($i);
print('</a> ');
$i++;
}


It may be a bit sloppy; but it works.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Prolly a stupid question

Developer Shed Advertisers and Affiliates



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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap