PHP
  Home arrow PHP arrow Page 2 - Paginating MySQL Data with PHP
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Paginating MySQL Data with PHP
By: Adrian Portsmouth
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 47
    2003-03-27


    Table of Contents:
  • Paginating MySQL Data with PHP
  • Getting Started
  • Making a Connection
  • Limiting the Dataset
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Paginating MySQL Data with PHP - Getting Started
    ( Page 2 of 5 )

    So lets get started going through the various parts of the code. At the end I will display it all together and you should be able to read and understand what it is doing.

    The first thing to do is set the variables that the script will need in order to work correctly. The variables may change at some point, so we put them at the top of the script where they are easy to find if we need to change them. If they are used multiple times within the script we will only need to edit them in one place.


    // Set Script Variables $DB_Host="localhost"; $DB_Name="MyDataBase"; $DB_User="MyUserName"; $DB_Pass="MyPassword"; $Per_Page=10;
    As I said these variables will be used in various stages of the script. We will now go through them one by one. $DB_Host should contain the host name where your MySQL resides, in most cases this is 'localhost'. The next three variables are used to connect to your MySQL database; $DB_Name will be the name of the database, $DB_User should contain your MySQL username and $DB_Pass should contain your MySQL password. Finally $Per_Page, this variable defines how many results will be displayed on each page. In this article we are going to display 10 results per page, but you can change this figure to any number that suits your system and layout.

     
     
    >>> More PHP Articles          >>> More By Adrian Portsmouth
     

       

    PHP ARTICLES

    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    Stay green...Green IT