General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

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:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old April 2nd, 2003, 01:03 AM
stfu stfu is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 19 stfu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Limit per Page

how can make output from search to be limited x number per page ?

Reply With Quote
  #2  
Old April 2nd, 2003, 12:17 PM
rickwright rickwright is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Nova Scotia
Posts: 27 rickwright User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Which programming tools - which db

Reply With Quote
  #3  
Old April 2nd, 2003, 04:17 PM
Kriek Kriek is offline
Integer Doctor
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Florida
Posts: 21 Kriek 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 Kriek Send a message via AIM to Kriek Send a message via Yahoo to Kriek
Assuming you are using PHP and MySQL

PHP Code:
 $query "SELECT * FROM table ORDER BY id DESC LIMIT 0,5"


Starting with row 0, limit the result to 5 rows.

Just keep in mind if you only use one parameter, it will be the number of rows to return, if you use two parameters, it will be where to start, and then the number to return. Start at row * and pull * results.

Reply With Quote
  #4  
Old April 3rd, 2003, 09:55 AM
stfu stfu is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 19 stfu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
yes i use php+mysql and this works but if i wants to show links for next page ? something like that let say you type keyword and matches in db for this keyword are 50 you limit output for 20 per page and you want other 30 outputs to be shown in two more pages on each you have 1,2, next previews how can make that ?

Reply With Quote
  #5  
Old April 3rd, 2003, 12:28 PM
rickwright rickwright is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Nova Scotia
Posts: 27 rickwright User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Assign the starting number the first page starts at 0
So $start_number = 0;
Execute your query ,and display your results.

If you want to show links to all pages that match your query
get a count of the number of records that match

//Divide that by the number of records, displayed per page.


print "<A href = $SERVER['PHP_SELF']?start_number=0 >First</a>";

$new_start_number = ($start_number - $num_records_per_page) -1;
print "<A href = $SERVER['PHP_SELF']?start_number=$start_number >Previoust</a>";

//Set up a loop to print out the results

$number_of_Links = $rec_count/$num_records_per_page
$j = 0;
while($j < $number_of _links){
$new_start_number = $start_number +
$number_displayed_on_page + 1;
print "<A Href =$SERVER['PHP_SELF']?
start_number=$new_start_number >$new_start_number</a> |
}
$new_start_number = $start_number + $num_records_per_page) +1;

print "<A href = $SERVER['PHP_SELF']?start_number=$new_start_number >Next</a>";

There may be some errors in this code; but it should be fairly close to what you need

hopr this helps

Reply With Quote
  #6  
Old April 3rd, 2003, 03:39 PM
rickwright rickwright is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Nova Scotia
Posts: 27 rickwright User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
New article here that should help

http://www.devshed.com/

Reply With Quote
  #7  
Old April 5th, 2003, 06:48 AM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
what your looking for is a programing function called "paging", this means that you display a query over multiple pages.

DevArticles has an article on this. check out:

URL

Reply With Quote
  #8  
Old April 5th, 2003, 08:05 AM
nicat23's Avatar
nicat23 nicat23 is offline
Addicted to Chaos..
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: Ft. Worth, TX
Posts: 653 nicat23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 47 m 52 sec
Reputation Power: 0
Send a message via AIM to nicat23 Send a message via Yahoo to nicat23
Thanks Ben! I can use that to help me with my mail client

Reply With Quote
  #9  
Old April 5th, 2003, 11:28 AM
jpenn jpenn is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Washington, DC
Posts: 317 jpenn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 3 sec
Reputation Power: 6
Quote:
what your looking for is a programing function called "paging"

Actually, the correct terminology for it is "Paginating" - - -
__________________
~ Joe Penn

We work for free to help make this a valuable resource on the internet. Do you appreciate the help - did we provide help that will help you prosper and help that has contributed to sharpening your current skill set?

Show your appreciation and purchase something from our Amazon Wishlist's - it's simple and a great way to say thank you.




Reply With Quote
  #10  
Old April 5th, 2003, 10:58 PM
Kriek Kriek is offline
Integer Doctor
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Florida
Posts: 21 Kriek 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 Kriek Send a message via AIM to Kriek Send a message via Yahoo to Kriek
Quote:
Originally posted by Ben Rowe
what your looking for is a programing function called "paging"


*cough* Hahah!

[Pagination] tutorial


Last edited by Kriek : April 5th, 2003 at 11:02 PM.

Reply With Quote
  #11  
Old April 6th, 2003, 07:48 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Im only human

Reply With Quote
  #12  
Old April 6th, 2003, 10:49 PM
nicat23's Avatar
nicat23 nicat23 is offline
Addicted to Chaos..
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: Ft. Worth, TX
Posts: 653 nicat23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 47 m 52 sec
Reputation Power: 0
Send a message via AIM to nicat23 Send a message via Yahoo to nicat23
Quote:
Originally posted by Ben Rowe
Im only human


We can't have humans!! We must all assimilate..

Whatever.. it's just a spelling error.. you guys got the point, right?

Reply With Quote
  #13  
Old April 6th, 2003, 11:47 PM
jpenn jpenn is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Washington, DC
Posts: 317 jpenn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 3 sec
Reputation Power: 6
Quote:
Originally posted by Ben Rowe
Im only human


No your not - don't try to fool us

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Limit per Page


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 6 hosted by Hostway