I've recently posted a thread (http://www.sitepointforums.com/showt...threadid=22215) about a kind of site map... But I have another problem... which is about the mentioned thread, but more complicated.
As you can read in the above mentioned thread I have a database with the following tables:
- table cats (id, titel) 'titel is dutch for title'
- table subcats (id, cat, titel) cat = foreign key to table cats.id
but also:
- table pages (id, subcat, txt, rubriek)
A page is the text of the subcategory, and lists the 'rubrieken' which appear on the site.
rubriek is dutch for section.
subcat = foreign key to table subcats.id
rubriek = foreign key to table rubrieken.id. A page can have 0, 1 or more 'rubrieken'.
- table rubrieken (id, titel)
- table links (id, rubriek, txt, email, titel)
rubriek = foreign key to table rubrieken.id. A link (basically an article) belongs to a 'rubriek'.
------
I know this database schema really s*cks. I know there are much better ways to accomplish the things they intend to with this database.... Unfortunately, I cannot change the database at this time... (ARGH!!!!)
So, what it simplified looks like;
cats -> subcats (<-cat) -> pages (<-subcat, rubriek->) -> rubrieken -> links (<-rubriek)
----
What do I want to do???
I want a sitemap which elaborates on the one mentioned in the above topic.
This one shows a map like:
---
Category 1 'titel of category'
... 1.1 'titel of subcategory'
... 1.2 'titel of subcategory'
Category 2 'titel of category'
... 2.1 'titel of subcategory'
... 2.2 'titel of subcategory'
---
It uses the following code:
What I want to accomplish is by clicking on one of the subcats (linking itself isn't the problem) you are shown the 'rubriek' (or plural) and the different links belonging to the subcategory. I don't mind if this is shown in a new page or on the page itself...PHP Code:$result = mysql_query("select * from cats order by id");
while($row = mysql_fetch_array($result)) {
extract($row);
$cats[$id] = array("titel" => $titel,
"subcats" => array()
);
}
//Get all the subcats and put them into the array at the corresponding main cat
$result2 = mysql_query("select * from subcats order by titel");
while($row = mysql_fetch_array($result2)) {
extract($row);
$cats[$cat]["subcats"][$id] = $titel;
}
foreach($cats as $key => $val) {
print "Categorie $key <b>".$cats[$key]["titel"]."</b><br>";
$i = 1;
foreach($cats[$key]["subcats"] as $jey => $jal) {
print " $key.$i $jal<br>";
$i++;
}
unset($i);
print "<br><br>";
}
// Thanks to FreddydoesPHP, BlackCat and FreakysID !!!
i.e.
----
Category 2 'titel of category'
... 2.1 'titel of subcategory'
...... 'titel of rubriek 1'
......... 'titel of link 1'
......... 'titel of link 2'
......... 'titel of link 3'
...... 'titel of rubriek 2'
......... 'titel of link 4'
......... 'titel of link 5'
......... 'titel of link 6'
-----
Because of the weird database structure I have no idea how to tackle this problem... Please help me!!!




Like I said, the structure sucks... the person who made this database should be shot.

Bookmarks