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]

Tags: php,javascript,html,css

Problem :

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

Solution :

As stated in the other answers, what you're trying to do is called pagination. This can be done with Javascript/jQuery or solely with PHP. The jQuery code is here. To do this in PHP, you'd do something like the following.

  1. Execute the SQL statement to get all of your results from the database and put them into an array.
  2. 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.
  3. 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.
  4. 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,100 on page 1 to LIMIT 100,100 for page 2, and so on.

    CSS Howto..

    How do I center the twitter bootstrap tabs on the page?

    How to specify the position of sub-menu div and prevent the menu div changed

    How to scroll .list-group leaving navigation bar at top

    How to make CSS width to fill parent?

    How to change the background color on a input checkbox with css? [duplicate]

    How I add a CSS class to first element of an array in PHP?

    How to make device width-height based html & css via PhoneGap

    How to save css stylesheet pointer on php session?

    How to set min-font-size in CSS

    How do I get a floating footer to stick to the bottom of the viewport in IE 6?

    CSS - How to center an image without class or id?

    How can i put random values to css properties using JQuery?

    How can I debug twitter bootstrap v4-alpha grid? col-sm-offset-* not working

    how to make divs adjust to dynamic screen resolutions?

    How to make “button-like appearance” with CSS

    CSS how to target background and make it transparent

    How to add fade in and fade out when changing between texts in javascript

    How to get CSS property value from HTML using generalistic JavaScript function
    When you use window.getComputedStyle the method directly return the style attribute calculated of your object. you can access directly the css attribute in the rreturn object. So to solve your...
    Read more

    CSS - How to match class (one dynamic and one static) between two elements

    How to align div blocks to be aligned in grid?

    C# How to base64 encode background gradient

    How to force div element to keep its contents inside container

    How do I prevent a link tag from adding extra padding below an image?

    How to add a repeating png image in the background of a webpage using CSS?

    How to change custom Check Box border with Dart

    How to adjust the position of specific elements/items/content on a page with CSS

    How to use vertical menus in HTML and css?

    How can I allign select menu with a button on the same line with css bootstrap?

    How to scroll through a div before the page scrolls?

    How to bring a specific overlayed image to the foreground