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.
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…
I’ve been getting more curious about MongoDB. The problem is I’ve been struggling trying to create a development environment. I’ve tried OSX, Ubuntu, and Windows. I always get stuck at a step. I think I found the right recipe. First, I’m running Windows 7 Professional 64 bit virtually. You don’t have to run Windows virtuall….
I recently found out how to install PEAR on a Godaddy shared hosting account. Visit http://pear.php.net/go-pear. Save the text displayed onto your desktop and name it go-pear.php. Upload this to your server. If you’re hosting multiple domains on the account, it’s best that you should upload this file in your root folder. Run this file…
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…
I was having a few problems creating a page with ampersands in the URL. This is a quick fix if it’s part of the HTML by using & but if it’s part of a javascript, it will take the code literally. For example, let’s say you have a javascript function that sends you to a…
I’ve been trying out the demo for Artisteer 2 and it’s great. Creating templates for popular CMS softwares such as WordPress, Joomla, and Drupal have never been easier. I’ve done some playing around with manually creating a WordPress template and it’s not too bad. The WordPress documentation is fairly easy to follow. But doing it…
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.