Dynamic standard php pagination class

Dynamic standard php pagination class

Ever had many pages on which you had to use pagination php script but had to use a different script for every single page? it is annoying isn’t it?
Well here is a solution, a pagination script that allows you to only use one script and pass as many parameters as you wish, including the url formatting for those who used htaccess rewriting for custom more friendly urls
the script is hosted on google codes, you can get it here, the project is licensed under the GNU GPL v3 license.
Feel free to use this code at your own risk, i hold responsible for no damage caused for the miss-use of this script, however for any questions, or bug reporting I’m here and would love to work on it and improve it further

Let’s now discuss how to use this script:

assuming of course that you’re already connected to database, we need no connection links, just the fact that the connection is established is enough for it to work

// if you hadn't already done so then connect to mysql db
$conn = mysql_connect('localhost','root','');
if(!$conn) die("Failed to connect to database!");
$status = mysql_select_db('database', $conn);
if(!$status) die("Failed to select database!");

now working with our class

//include the pagination class
//pagination class instance
$paginate = new pagination();
//call paginate function to return an array of pagination links + link query
$value_array = $paginate->paginate($_GET['page'], 3, 1, 'custom_format/', false, 'db_table', false, false);
* to pass custom mysql queries into the function parameters please write the clauses as is
* Exp: $value_array = $paginate->paginate($_GET['page'], 3, 1, 'custom_format/', false, 'db_table', 'WHERE something = something', false);
//get the returned data
$pagination_links = $value_array['pagination'];
$pagination_data = $value_array['data'];

manipulating the data returned by the script

//loop through the query link results
while($pagination_result = mysql_fetch_array($pagination_data))
   //do your stuff here	

Finally, output the navigation links

<?=$pagination_links; ?>

The above code is a short hand php code, if your server doesn’t allow it then simply use the echo statement to output the links

Alright, that was it! let me know if you need any help with it, share and pass the article on if you found it to be useful.

Abdelkader Soudani

About Abdelkader Soudani

Abdelkader Soudani is the Founder and Director of Sproweb International, He is also a web developer/designer who specializes in front and back end development, Iphone and Android development, marketing and video production. If you'd like to connect with him then head over to the contact page or his profile on Google Plus.

156 comments on «Dynamic standard php pagination class»

  1. Terese says:

    Wow, wonderful blog layout! Howw lоng have yоu bеen blogging for?
    you make blogging looκ easy. The overall lօoқ of your website
    is magnificent, lеt alone the content!

  2. Jewel says:

    An impressive share! I have just forwarded this onto a coworker who had been conducting a
    little homework on this. And he in fact bought me lunch due to the fact that I stumbled upon it for him…

    lol. So let me reword this…. Thanks for the meal!!
    But yeah, thanx for spending some time to talk about this topic here on your web site.

  3. Marguerite says:

    Howdy! I’m at work browsing your blog from my new iphone!
    Just wanted to say I love reading through your blog and look forward to all your posts!
    Keep up the fantastic work!

  4. Red Toms says:

    Wow, this piece of writing is nice, my younger sister is analyzing these things, so
    I am going to tell her.

  5. Lucile says:

    Thank you for the good writeup. It in truth was a amusement account it.
    Glance advanced to far delivered agreeable from you!
    However, how could we communicate?

  6. CT says:

    Helpful info. Lucky me I discovered your website unintentionally,
    and I’m stunned why this accident did not happened in advance!
    I bookmarked it.

  7. netti kasino says:

    bookmarked!!, I like your site!

    Here is my website … netti kasino

  8. Sylvia says:

    I am not sure where you are getting your info, but great topic.
    I needs to spend some time learning much more or understanding more.
    Thanks for great information I was looking for this information for my mission.

    Stop by my web blog :: Sylvia

  9. Billie says:

    I was recommended this web site by my cousin. I’m not sure
    whether this post is written by him as nobody else know
    such detailed about my trouble. You are incredible! Thanks!

  10. Thank you for sharing your info. I really appreciate your efforts and
    I will be waiting for your further post thank you
    once again.

  11. I like the helpful info you provide in your articles.
    I will bookmark your weblog and check again
    here regularly. I am quite sure I will learn many new stuff right here!
    Good luck for the next!

  12. I like reading through an article that will
    make people think. Also, many thanks for allowing for me to comment!

  13. Mdhuset says:

    Amazing issues here. I am very happy to see your article.
    Thank you a lot and I’m taking a look ahead to
    contact you. Will you kindly drop me a mail?

  14. I really like it when individuals come together and sharre opinions.

    Great site, stick with it!

  15. What’s Taking place i amm new to this, I stumbled upon this I’ve found It absolutely useful and iit has
    helped me out loads. I hope to contribute &
    help different customers like iits helped me. Good job.

  16. Carrie says:

    Have you ever thought about adding a little bit more than just your articles?
    I mean, what you say is important and everything. However think of if you added some great pictures or videos to give your posts more, “pop”!

    Your content is excellent but with pics and video clips,
    this blog could definitely be one of the very best in its field.
    Amazing blog!

  17. Great article. I will be facing a few of these issues as well..

  18. Hey! This post couldn’t be written any better! Reading through this post reminds me
    of my good old room mate! He always kept talking about this.
    I will forward this page to him. Fairly certain he will have a good read.

    Many thanks for sharing!

  19. terry bandy says:

    Thanks for finally writing about > Dynamic standard php pagination class | Abdelkader Soudani < Loved it!

  20. Latia says:

    Thanks on your marvelous posting! I actually enjoyed reading it, you can be a great author.
    I will ensure that I bookmark your blog and will come back at some point.
    I want to encourage you to continue your great work,
    have a nice day!

  21. Carmella says:

    I read this article fully about the comparison of hottest and preceding
    technologies, it’s remarkable article.

  22. Good blog you have here.. It’s hard to find good quality writing like yours these days.
    I seriously appreciate individuals like you!
    Take care!!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>