I have a site where members can sell items and place them in categories and sub-categories.
When a buyer views an item page, I would like to display 10 random items being sold by the same member. So far, everything is working fine:
$sql = "SELECT * FROM items WHERE seller = '$seller' ORDER BY RAND() LIMIT 10";
I would like to show similar items related to the category that the item page is listed in, rather than totally random, un-related items.
For example, here are some categories:
Collectibles > Bottles
Collectibles > Coins/Banknotes > Coins
Collectibles > Coins/Banknotes > Banknotes
Collectibles > Comic Books
Movies > DVDs
Movies > VHS
Let's say this member has thousands of items listed in all of these categories. When a buyer looks at an item listed in: "Collectibles > Coins/Banknotes > Coins" , I would like to show random "Coins" items from this seller. If he has less than 10 coins for sale, I would like to then show random "Coins/Banknotes" items. If there are still less than 10 items, show random "Collectibles". Basically the randomness starts specifically and then grows more general.
I hope this description is understandable. Please let me know how this could be done.