Jump to content

I have a categories table and a listings table. - pulling the two together?


Whizzell

Recommended Posts

I have my categories table, which holds all the categories on my site in one table.

It has these fields:

catid,
parentid,
level, 
name,
desc.

 

I need to find a way to select all the listings from my listings table where its catid is either equal to the pages catid or the parentid is equal to the pages catid.

 

each listing has a field called 'cat' which refers to the catid of the subcategory that it is in. I can get my page to display all the records in a sub-category but if they choose the category above the listings from all the subcategories do not also display.

 

I think i may have to use a select join query but i'm not sure. i can't seem to find a tutorial whereby i can select * from categories where id = $cat OR parentid = $cat;

 

for each result select * from listings where cat = $cat_result;

 

I think i need something similar to that but i have no idea how the syntax should go or how i can get it to keep running the second select query until all the different subcategories are included in my search for listings.

 

Help needed as soon as possible. Thanks in advance.

 

Site is live at http://nath.slizzsavings.co.uk

 

Will.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.