i suppose your db structure looks something like this:
cat
+--------------+--------------+
| id | title |
+--------------+--------------+
| 1 | shirts |
| 2 | pants |
| 3 | shoes |
| 4 | hats |
+--------------+--------------+
item
+--------------+--------------+--------------+
| id | cat | title |
+--------------+--------------+--------------+
| 1 | 1 | blue t-shirt |
| 2 | 1 | red t-shirt |
| 3 | 2 | jeans |
| 4 | 3 | all stars |
| 4 | 3 | vans |
| 4 | 3 | pumas |
| 4 | 4 | baseball cap |
+--------------+--------------+--------------+
to display the category links:
$result = mysql_query("SELECT *
FROM cat;")
while ($row = mysql_fetch_array($result)) {
print "<A HREF=\"cat_items.php?cat=" . $row[id] . "\">" . $row[title] . "</A><BR>";
}
cat_items.php:
$result = mysql_query("SELECT *
FROM item
WHERE cat = " . $cat . ";")
while ($row = mysql_fetch_array($result)) {
print "id: " . $row[id] . "; " . "title: <A HREF=\"item.php?item=" . $row_item[id] . "\">" . $row_item[title] . "</A>;<BR>";
}
to display it all in one navigation (there are simpler ways in oracle to do so in 1 query - im not sure about mysql):
$result = mysql_query("SELECT *
FROM cat;")
while ($row = mysql_fetch_array($result)) {
print "<A HREF=\"cat_items.php?cat=" . $row[id] . "\">" . $row[title] . "</A><BR>";
$result_item = mysql_query("SELECT *
FROM item
WHERE cat = " . $row[cat] . ";")
while ($row_item = mysql_fetch_array($result_item)) {
print " - <A HREF=\"item.php?item=" . $row_item[id] . "\">" . $row_item[title] . "</A><BR>";
}
}
since you are talking about links, just replace the
item.php?item=" . $row_item[id] . "
link with your link address,