Hi guys.

I already know how to set up a pagination script.

But I only know how to use a simple < previous | next > pagination script.

What I want to be able to do is set up a pagination script which gives a string of numbers. e.g - [1-2-3-4-5-6-7-8-9-10],,,, rather than the simple < previous | next > links.

I want each of these numbers [1-2-3-4-5-6-7-8-9-10] to link to and fetch 10 rows from the database when clicked.

The thing is, I don't know where to start and what functions would come in handy to make this work?

Obviously I would need to set up a class (I imagine).

I guess what I am trying to say is that fetching the rows from the database would not be a problem. I can do this but the one and only thing I am struggling to find an answer to is how I would automatically generate the additional numbers to the pagination script? For example, if there is 35 rows in the database, the pagination would only display [1-2-3-4]

How do I get this type of effect?

Paul.

    You'll need a query to get the total number of matching rows so you can figure out how many pages you have (divide by the number of rows per page and round up). With MySQL you can optimize this process a bit by using it SQL_CALC_FOUND_ROWS option: https://stackoverflow.com/questions/12887266/get-total-number-of-rows-when-using-limit#12887293 . You still have to make two queries, but the second (to get the total matching rows) will be more efficient than just doing the same query without the offset/limit you would for getting the rows for one page.

      8 days later

      Thanks NogDog.

      I am familiar with the use of SQL_CALC_FOUND_ROWS

      But could you give me a script example in regards to where you say:

      You'll need a query to get the total number of matching rows so you can figure out how many pages you have (divide by the number of rows per page and round up).

      .... so I can better understand how it is done.

        Paul help!;11063649 wrote:

        Thanks NogDog.

        I am familiar with the use of SQL_CALC_FOUND_ROWS

        But could you give me a script example in regards to where you say:

        .... so I can better understand how it is done.

        When you were trying to display the last ten items in a database, this was suggested and a tutorial was linked to you by myself, here it is again

        tutorial

          Write a Reply...