O'Reilly logo

CodeIgniter 2 Cookbook by Rob Foster

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding and searching by product categories

From a customer perspective, it is useful to be able to narrow down your catalogue by viewing products by category, such as shoes, shirts, coats, and so on. If you wish to add this functionality, you'll need to amend the database. If you require this feature, copy the code in the following Getting ready section.

Getting ready

In order to support searching and filtering by categories, we'll need to add a categories table. If you haven't already done this during the Getting ready section earlier in the chapter, create the following table in your database:

CREATE TABLE IF NOT EXISTS `categories` ( `cat_id` int(11) NOT NULL AUTO_INCREMENT, `cat_name` varchar(50) NOT NULL, PRIMARY KEY (`cat_id`) ) ENGINE=InnoDB ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required