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 ...

Get CodeIgniter 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.