|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
Limit per Page
how can make output from search to be limited x number per page ?
|
|
#2
|
|||
|
|||
|
Which programming tools - which db
|
|
#3
|
|||
|
|||
|
Assuming you are using PHP and MySQL
PHP Code:
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. |
|
#4
|
|||
|
|||
|
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 ?
|
|
#5
|
|||
|
|||
|
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 |
|
#6
|
|||
|
|||
|
|
|
#7
|
|||
|
|||
|
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 |
|
#8
|
||||
|
||||
|
Thanks Ben! I can use that to help me with my mail client
![]() |
|
#9
|
|||
|
|||
|
Quote:
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. |
|
#10
|
|||
|
|||
|
Quote:
*cough* Hahah! [Pagination] tutorial Last edited by Kriek : April 5th, 2003 at 11:02 PM. |
|
#11
|
|||
|
|||
|
Im only human
|
|
#12
|
||||
|
||||
|
Quote:
We can't have humans!! We must all assimilate..Whatever.. it's just a spelling error.. you guys got the point, right? ![]() |
|
#13
|
|||
|
|||
|
Quote:
No your not - don't try to fool us ![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Limit per Page |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|