-2

Is there any way to create next page automatically when there are more than 20 rows?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Hammad
  • 173
  • 1
  • 1
  • 6
  • what do you mean with "next page"? do you have a code sample for us? – brainbowler Jul 24 '14 at 22:05
  • Bro i am Getting data from my mysqldatabase and i want when the data is more then 20 rows it will automatically create next page or view Next link so user can see more data – Hammad Jul 24 '14 at 22:05
  • if you aren't more precise, we won't be able to help. so, again: what do you mean with "next page"? – brainbowler Jul 24 '14 at 22:08
  • Bro Do u use Gmail ?? when u click on inbox all emails are come from database but when u click on next button then other 20 will show up – Hammad Jul 24 '14 at 22:10
  • http://stackoverflow.com/questions/3705318/simple-php-pagination – andrewsi Jul 24 '14 at 22:11

2 Answers2

1

You will need to use a sql limit to limit the output for 20 rows, then a link at the bottom of the page to create a new page with a new limit of 21-41 and so on...

SELECT * FROM TABLE LIMIT 0, 20

That will output the first 20 lines, then you'll need to programatically do the following

SELECT * FROM TABLE LIMIT 21, 41

You will need to hold the variables in a PHP statement, and when the user presses the next page button, it will $_GET the variable from the header and add 20 to each of the numbers.

James Simpson
  • 197
  • 2
  • 16
0

If you want a frontend-side pagination only (and do not handle lots of data), have a look at this jQuery plugin:

https://datatables.net/

This is easy to integrate and very useful!

If you are talking about a server-side pagination, see http://www.techumber.com/2012/08/simple-pagination-with-php-mysql.html. If you do not like that specific one, there are plenty of these tutorials out there.

The basic knowledge you need for the SQL side of things can be found here: http://www.petefreitag.com/item/451.cfm

brainbowler
  • 667
  • 5
  • 17