Two queries will be used for this task. The first query, you will count the rows of the recordset. The second query is the same as the first but it will have the LIMIT – this is what will be used to display the data on each page.
Let’s say we have the following table.
Now we’ll query the database and get the row count using PDO.
If you don’t use the bindValue, you will get an error in your query. Your second query would look something like this….
…and the error would occur right after LIMIT. You cannot have quotes surrounding the numbers. It took a few hours of Googling but found the solution.
In the past it was always a bit challenging to get WIMP installed, at least for me it was. I ended up using installers for PHP and even then which version would I use, fast cgi or that other one (can’t seem to remember the name, it’s been a while). Recently, I had to create…
I’ve been checking out Python and Django and I’m impressed at what it can do. It’s efficient and has more things built-in compared to PHP and CodeIgniter. Unfortunately, I ran into some issues when installing the python-mysqldb. Without it, I can’t connect to MySQL – I could do sqlite3 fine though. I have existing projects…
This will show you how to create a CakePHP environment in MAMP on OS X. Here list of softwares used and their version. OS X Leopard or Snow Leopard MAMP version 1.91 (using PHP5.2.x) CakePHP 1.2.8 You shouldn’t have to use MAMP 1.9.1. I have it working on version 1.8.x. You will need to change…
I have been messing around with jQuery for a couple of days now and I think I’m getting the hang of it. Before using jQuery, I was using Mootools for processing forms to divs. It worked as intended but what I couldn’t do was create new javascript within the loaded pages. As interfaces get more…
I’m using the jQuery plugin from http://bassistance.de/jquery-plugins/jquery-plugin-validation. The plugin is greate. I did run into a problem with arrays. Say your form has a group of checkboxes or radio buttons and their names are checkbox or radio. To have them be in the same group, their names have to be the same and to process…
I’ve been developing web sites for almost 10 years now. I’m still in search of a way to develop faster. I find myself doing things over and over again. I use PHP as the programming language to develop the web apps with MySQL database. I started to look for different frameworks – but most use…
One Comment
Thanks a whole bunch for this tutorial. It was a big help for a custom CMS I am writing. Once it is finished I will give you a thank you mention. Don’t understand why no one commented here. This is the only tutorial on making Pager work with PDO I could find. Thanks again.
Thanks a whole bunch for this tutorial. It was a big help for a custom CMS I am writing. Once it is finished I will give you a thank you mention. Don’t understand why no one commented here. This is the only tutorial on making Pager work with PDO I could find. Thanks again.