How to display multiple categories and products underneath each category?

Posted by shin on Stack Overflow See other posts from Stack Overflow or by shin
Published on 2010-05-16T20:28:06Z Indexed on 2010/05/16 20:30 UTC
Read the original article Hit count: 227

Filed under:
|
|

Generally there is a category menu and each link to a category page where shows all the items under that category.

Now I need to show all the categories and products underneath with PHP/MySQL in the same page.

So it will be like this.

Category 1
description of category 1
item 1
item 2
..

Category 2
description of category 2
item 5
item 6
..

Category 3
description of category 3
item 8
item 9
...

...

I have category and product table in my database.

But I am not sure how to proceed.

CREATE TABLE IF NOT EXISTS `omc_product` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `shortdesc` varchar(255) NOT NULL,
  `longdesc` text NOT NULL,
  `thumbnail` varchar(255) NOT NULL,
  `image` varchar(255) NOT NULL,
  `product_order` int(11) DEFAULT NULL,
  `class` varchar(255) DEFAULT NULL,
  `grouping` varchar(16) DEFAULT NULL,
  `status` enum('active','inactive') NOT NULL,
  `category_id` int(11) NOT NULL,
  `featured` enum('none','front','webshop') NOT NULL,
  `other_feature` enum('none','most sold','new product') NOT NULL,
  `price` float(7,2) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;



CREATE TABLE IF NOT EXISTS `omc_category` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `shortdesc` varchar(255) NOT NULL,
  `longdesc` text NOT NULL,
  `status` enum('active','inactive') NOT NULL,
  `parentid` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

I will appreciate your help.

Thanks in advance.

© Stack Overflow or respective owner

Related posts about beginner

Related posts about php