Hi folks,
I need a little help working out a 2 tier navigation that is database driven as I'll need to use CMS to insert new categories and topics at a later date.
The navigation is in unordered list format looking similar to below. Two category listed navigation with two sub topics for each as a basic example. Some categories will have more or less topics.
<ul>
<li>
Category 1
</li>
<ul>
<li>
Topic 1
</li>
<li>
Topic 2
</li>
</ul>
<li>
Category 2
</li>
<ul>
<li>
Topic 1
</li>
<li>
Topic 2
</li>
</ul>
</ul>
I've built two tables in preparation
tblCategory
cat_id as primary key
cat_name as nvarchar
tblTopics
topic_id as primary key
topic_name as nvarchar
cat_id as foreign key
I've read it's also possible and probably a better idea to have 1 table, then using parent, child to array the data. I'm keen to look at that as well.
So the question is, how do I loop the database records through these nested unordered lists?
Thanks in advance