Have a large MySQL dataset that you would like to display on your website, but don't want to bog down your users' connections with large HTML renderings? Try paginating your data.
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.