Im trying to figure out if this is possible, and ive come to my wits end in trying different methods.
Im trying to select a group of products from a database, the problem being that products can be split across more than one subcategory, but still reside in the same main category.
Im using this code to select the categories:
$categories = mysql_query("SELECT categories_id FROM categories WHERE parent_id = $_GET[cPath]");
and Ive used this code so far to select the products:
$products = mysql_query("SELECT products_id, products_quantity, products_image, products_price FROM products WHERE products_status = 1 AND master_categories_id = $echo_categories[categories_id] ORDER BY rand() LIMIT 10");
I would like to be able to display all the products across the categories in a random order. (EG. A product from subcategory 1 would be followed by 1 from subcategory 4, then maybe 2 from subcategory 3 etc). So far I have tried using a while() loop to output the records, but obviously because the while loop is only working on one subcategory at a time it will only select the products in that subcategory.
Really what I need to do is be able to select all the products which have a 'master_categories_id' value which exists in the categories array selected earlier. If that makes sense :|
Any help would be grately appreciated thank you!