| Ok we are not going to waffle on about pagination but we will try and throw up a solution for you. First lets look at the scenario.
Scenario.
We have a database with hundreds of links and wish to display them , we cannot display all of the items as there is to many to view in one go. We would like to give the user the ability to view all records in the database , say 25 at a time.
The database in our example has the following structure
CREATE TABLE `nuke_links_links` ( `pn_lid` int(11) NOT NULL auto_increment, `pn_cat_id` int(11) NOT NULL default '0', `pn_title` varchar(100) NOT NULL default '', `pn_url` varchar(254) NOT NULL default '', `pn_description` text NOT NULL, PRIMARY KEY (`pn_lid`) ) TYPE=MyISAM
This is the modified web links part of PHP-nuke which consists of a unique ID for each entry called pn_lid, pn_cat_id is the category id, pn_title is the title of the link, pn_url is the url and pn_description is a description of the link. We use this for affiliate links.
What we wish to do is display the title, link and description for every link in a category. The category is PHP and its unique number is 98 Solution
We are going to use a couple of the packages from the pear website database section . These are the db package and the DB_pager package. Download them and install them in a folder , we have a simple example detailing this or check out the Pear website. |