well, I have a new problem...
I have two tables. 'Category' (items are 'ID' and 'title') and 'Subcategory' (items are 'ID', 'Cat_ID' and 'title')
... I want to make a 'sitemap' (kind of) of the categories and the subcategories... which looks something like this:
----
Category 1 (title)
..Subcat 1.1 (title)
..Subcat 1.2 (title)
..Subcat 1.3 (title)
Category 2 (title)
..Subcat 2.1 (title)
..Subcat 2.2 (title)
..Subcat 2.3 (title)
et cetera....
----
I already have a statement for the retrieval of the subcaterogies:
----
<?
$sql = "SELECT * FROM subcats order by cat";
$result = mysql_query($sql);
while ( $row = mysql_fetch_array($result)) {
echo '<tr bgcolor="#FFFFCC">' . '
<td width=60 align="center">' . $row["id"] . '</TD>' .
'<td width=60 align="center">' . $row["cat_ID"] . '</td>' .
'<td valign="top">' . $row["title"] . ' ' . '</td>' .
'</tr>';
}
exit;
?>
---
This shows a table with a column of subcat ID's, a column of cat_ID's and a column of subcat titles.
Now the true problem lies in the combining of the two tables. Now I could probably link the cat_ID from the Subcategory table with the Category table. But how do I order the list in the way I showed at the beginning of this message.
Could someone help me with the code to solve this problem?






AFAIK, mySQL does not yet support UNION nor sub-queries (nested queries).
Well I guess that shows my experience level with MySQL. Thanks for pointing these things out. Now I don't feel so silly.

Bookmarks