0

Problem is this: I need to display products category/categories name when I am displaying products on a category page. Is there any way of doing that

Basically it would look like that: Category page

Product name Belongs to - Subcategory1 name

Product name Belongs to - Subcategory2 name

and etc.

Is there any way of doing that ?

1
  • 1
    There are a lot of ways to do a lot of things for a lot of different purposes.
    – DirtyBit
    Aug 25, 2015 at 14:11

1 Answer 1

0

thinking that you have a properly normalized database,

SELECT  `product`.`product_name` ,  `category`.`category_name` 
FROM  `product` 
JOIN  `category` ON  `category`.`category_id` =  `product`.`category_id`

loop through the results returned from above query where you can get product name and category and print them as you wish.

like HawasKaPujaari said, there are lot of ways to do this :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.