how to display only 100 rows of 1000 from a database with options to go to next 100 and previous 100 in html/php/css/js [closed]
so here what i wana do i wana display first 100 rows that i get from a database which has a total of 1000 or more rows.
now displaying all of them together can create problems in locating a particular row.
so i wana display the first 100 with option to go to next/previous etc, kinda like it is in the google search result..
see the pic:
how can this be done.. please give sample code/links which are usefull
- Execute the SQL statement to get all of your results from the database and put them into an array.
- Divide the number of elements in the array by however many results you want per page (100 in your case). So if you have 1000 records and divide it by 100 results per page, you'd get 10 pages.
- Each page link will correspond to a set of results that will be submitted on click. You can do this by making a POST or GET request (POST recommended). For example, the link for page 1 will get results 0-99, page 2 will get results 100-199, etc.
- Now when the user clicks a page link, it will POST the results, and you can use the parameters to adjust the SQL statement based on what page link they clicked on. Essentially, this should only modify the LIMIT part of your SQL statement. For example, if a user clicks page 2, the LIMIT clause in your SQL statement will go from being
LIMIT 0,100on page 1 to
LIMIT 100,100for page 2, and so on.