You are here:

PHP5/Need help how to get product

Advertisement


Question
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 :
category_id
parent_id

products_to_categories :
product_id
category_id

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.

---------- FOLLOW-UP ----------

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

Answer
Hello,
     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;

PSEUDO EXAMPLE:

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.

PHP5

All Answers


Answers by Expert:


Ask Experts

Volunteer


Vimal Abraham

Expertise

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

Experience

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, http://www.4kwallpapers.in http://www.wallpicz.com

Education/Credentials
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).

©2016 About.com. All rights reserved.