iEntry 10th Anniversary RSS Newsletter Advertising
Join the WebProWorld Forum!
Text: Decrease Font Size Increase Font Size | Print Print Article | Share: Delicious Digg StumbleUpon Post to Twitter Post to Facebook
Tuesday, June 20, 2006

PHP Pagination with MySQL

9 Comments

Thanks!

Thanks so much for this easy to understand code. It slipped perfectly into a new site I'm building with very few tweaks at all.

 

paging

Mike,

Thank you for the time and effort that you put into this tutorial.  You targeted those such as I, less experienced in mysql then I would like to be.

With a few fixes, it ran beautifully.  I'll take your encouragement and modify it into the script that I am working.

I've read through many a tutorial on this matter (rather simple once learned) and came out of it worse.

Then I came upon your writing.  Super~!

Thanks again.

Kind regards,

Al Toman

 

 

 

thanks alot very easy and

thanks alot very easy and self explained, appreciate your help, keep up the good work

thanx miky 

thanx miky 

Congratulations

Fantastic Page!! easy and powerful.

404 error when clicking pagination link

Hello and thank you for an awesome pagination tutorial!

I do have a problem with getting it to work properly when it comes to actually clicking the link that is formed during pagination. Every time I click on one of the pagination numbers (EG. the number 2) I get a 404 page not found error. I've tried a few things but cant seem to fix this. Anything special needing to be done?

Thanks!

Thanks for sharing your fix.

Thanks for responding with your fix, Sean!

Of Course.

It figures that right after posting that comment, I figure it out.

Using ' LIMIT x OFFSET y ' in your sql query takes care of all of that for you. In your example above, x would be $offset, and y would be ( $entries_per_page * $page_number ). I tried using the ' LIMIT x,y ' form on my version of MySQL, but it doesn't like me very much ( or more likely I'm just doing it wrong ).

Deleted entries?

What about when there are rows missing? For example, a user may delete posts from a blog, leaving rows missing. Then you may have id's jumping one or more at a time ( ie, 1,2,4,5,6,8,10 ). How would you deal with this? I've been working on this for a few days now, and it's starting to bug me.

So far the only idea I've is to try and figure out if there are any missing ID's on the last statement ( ie, your last page showed items 6,8, and 10 ), and then move forward the proper ammount. I'm still working on it, and hopefully I'll have something soon.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
4 + 3 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
SEARCH
Popular WPN Business Resources












Subscribe to WebProNews


Send me relevant info