Hi,
In my database I have tables for:
- Tools (sc_tools)
- Categories (sc_categories)
- Screencasts (sc_screencasts)
In the database there are connections between the mentioned as follows:
1) "sc_tools" has an id: tool_id
2) "sc_categories" has an id: (cat_id) AND a relation to sc_tools (cat_rel_to_tool - which is = tool_id)
3) "sc_screencasts" has an: id (sc_id) AND a relation to sc_tools (sc_rel_to_tool - which is = tool_id) AND a relation to sc_categories (sc_rel_to_cat - which is = sc_id)
Ok, so I want to list my data as follows:
Tool 1
- Category 1
- - Screencast 1.1
- - Screencast 1.2
- Category 2
- - Screencast 2.1
Tool 2
- Category 1
- - Screencast 1.1
osv.
I have been tryin with the JOIN-query:
$sql_screencasts = mysql_query("SELECT t.tool_id, t.tool_name, c.cat_id, c.cat_name_dk, s.sc_id, s.sc_desc_dk
FROM sc_tools t
JOIN sc_categories c ON c.cat_rel_to_tool = t.tool_id
JOIN sc_screencasts s ON s.sc_rel_to_cat = c.cat_id
");
while ($row_screencasts = mysql_fetch_array($sql_screencasts ))
{
$tool_name = $row_screencasts["tool_name"];
$cat_name_dk = $row_screencasts["cat_name_dk"];
$sc_desc_dk = $row_screencasts["sc_desc_dk"];
$sc_id = $row_screencasts["sc_id"];
echo "<br><font size=3><b>".$tool_name."</b></font><br>";
echo "- ".$cat_name_dk;
echo "<br>- - <a href='view.php?id=".$sc_id."'>".$sc_desc_dk."</a><br>";
}
But is lists the data as:
Tool 1
- Category 1
- - Screencast 1
Tool 1
- Category 1
- - Screencast 2
etc. - I can't get e GROUP BY working either, so I'm lost right now. Hopefully an expert can help me out? Any help is highly appreciated!