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:
  #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 48 m 34 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: 8
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 48 m 34 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: 8
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




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

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




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 8 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek