You are here:

PHP5/Need help how to get product


QUESTION: Hi,how are you?I would like to ask for a help.I would like to get products where products belong to category and subcategory.This is the tables i got.

categories table :

products_to_categories :

Thanks a lot.

ANSWER: Hello handoyo,
         Could you please be specific ?
Also, which is the category table and which is the sub category, because i can't find any 'subcategory' name in the tables given.

[an error occurred while processing this directive]---------- FOLLOW-UP ----------

QUESTION: Hi,the category and the subcategory was in the same table.the category id and the parent id.thanks

     My apologies that i am unable to get you clearly. Anyhow, i am assuming that you are asking about how to select similar data from two columns from a table.

If so, that would be like the following.

select product from categories_table where category_id=value and parent_id=value;


select * from planets where solar_system='earth' and universe='earth';

assuming, the table is named as 'planets'. And, there are two columns named solar_system and universe.

The above command fetches the planets that are present both in 'solar_system' field and 'universe' field.

If the above mentioned were not the one you are trying to ask, feel free to write back to me, more briefly. Attach snaps if possible.

Thank You and all the best.


All Answers

Answers by Expert:

Ask Experts


Vimal Abraham


I can be able to solve PHP, MySQL and Web Hosting (Linux) related issues that may include cPanel/WHM.


I have worked under various domains of web development including file sharing, social community, wallpaper management, image hosting, web hosting automation, shopping cart and payment gateway integration. My active portfolios include,

I have completed Bachelor of Engineering in Computer Science.

Awards and Honors
Have a Total of nine certificates in Inter and Intra College Competitions that includes technical quiz, program debugging and paper presentation (State Level).

©2017 All rights reserved.

[an error occurred while processing this directive]