I know this sounds confusing:
I have just built some basic prev/next pagination for mysql and i wanted to know, if the last page of my rows is .php?page=5 and someone puts .php?page=263 then i want to redirect them to .php?page=5
Any ideas on how to do this.. the info i currently have is, how many rows are returned after the LIMIT so if it was .php?page=263 then it would be 0
I also have the total number of rows in my database… the LIMIT is 10 🙂
Thanks in advance!!
If you already have the total number of rows, and you know how many rows you will be displaying per page, then you can calculate the last page like so:
Then, simply restrict the current page to a reasonable limit: