|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
i want search results to be limited to 10 records per page.
say, if a search on a database return 95 records, i want the results to be formatted to 10 pages. how do i do that ? thanks |
|
#2
|
|||
|
|||
|
select * from table_name limit 10
and for next page: select * from table_name limit 10, 10 |
|
#3
|
|||
|
|||
|
What you see in the last example is SQL's LIMIT and OFFSET functions. The syntax above is for MySQL. Other SQL DB's format it slightly differently:
select * from table_name limit 10 offset 10 Basically your SQL engine does the query and then returns only 10 records (the limit) starting with the 10th record in the query result (the offset). You can then display the entire query result on your page and know that it'll only have 10 lines. You'll need to set up a system for tracking the offset so you can create NEXT and PREVIOUS functions that simply +10 or -10 the offset and display the new results on a fresh page. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > PHP Development > how to limit the seach to 10 records per page ? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|