Paginating data for large record sets
It is best to break down a long list into separate pages and navigate them with buttons such as Previous, Next, and specific page numbers. In this recipe, we will take a long list of HTML elements and will paginate them into separate pages with a fixed number of items per page. We will also provide the user with options to jump to any page using a select box.
Getting ready
Create a folder for this recipe inside the Chapter8
directory and name it as Recipe5
. Using phpMyAdmin, create a table named movies
with the following structure:
CREATE TABLE IF NOT EXISTS `movies` ( `id` int(11) NOT NULL AUTO_INCREMENT, `movieName` varchar(64) NOT NULL, PRIMARY KEY (`id`) );
For pagination, we will require a long list so as to enter some movie names in this table, using phpMyAdmin. For this example, we have already inserted 100 names in the table. You can use the movies.sql
file that will be supplied along with this book to populate the table. Names of movies in...