Selecting Items for Child Categories?

03-14-2007, 12:28 PM

I have a links system that has categories. Each category either has links or more categories. I need to randomly get 5 links to display in the main content area, if the category only contains more categories. The problem is I only want random links from the categories below the current category.

For news, I could have any link in New York, California, or Canada. USA wouldn't have any links as all those would have to either be in New York or California. Another issue is the depth isn't always known. For news, 1 and 2 levels down contain links. For music, the 3rd level contains the links. Is there a way to get random links from only the categories below? Is there a better way to set up the table?