Hi,
I just can't seem to figure this out, my brain is about to explode.
Here is an explanation of the application:
I have 2 sql tables (categories and subcategories), the subcategories table has a field called "category_included_in" which is a relational mirror of the "id" field in the categories table. Querying this information doesn't appear to be a problem, see below:
$rowset = $dbclass->database_sql("SELECT categories.category, subcategories.subcategory
FROM categories, subcategories
WHERE categories.id = subcategories.category_included_in
ORDER BY category");
while ($rows = mssql_fetch_array($rowset)) {
$cat_list .= "
<p><strong>$rows[category]</strong></p>
<li> $rows[subcategory]";
}
The challenge is that I would like to display the subcategory results like this:
CAT1
subcat (under cat 1)
subcat (under cat 1)
CAT2
subcat (under cat 2)
Instead my results repeat the category and don't group the subcategories:
CAT1
subcat (under cat 1)
CAT1
subcat (under cat 1)
etc.
Please HELP!
Dan