Jump to content

Loops or arrays or is it even possible?


klewis

Recommended Posts

Hi I am creating a shopping directory and I want to list related shops which are defined by the subcategory the are in.what I'm trying to achieve is a recordset that gets all the subcategories for that particular shop (sql1=select subcategory_id from search_cat where shop_id =1)and another recordset that uses the subcategory values ($subs) to bring up other shops in the same subcategory. (sql2= select search_cat.subcategory_id, shop.shop_id, shop.name from search_cat left join shop on (shops_id=shop_id) where $subs = search_cat.subcategory_id).I have this working to an extent - but it will only bring up related shops in the first subcategory on the list and not all of them. Do I need to a loop to get this to loop through all the subcategories or do I need to output sql1 as an array or none of the above! Is this even possible? Any pointer will be greatly appreciated.Many thanks in advanceKelly

Link to comment
Share on other sites

Why are you doing the left join on search_cat, do you want all records from search_cat? On this statement:on (shops_id=shop_id)You'll need to say which tables those belong to, i.e. shops.shop_id=search_cat.shop_id.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...