Okay, I've been working on this one for a few weeks now and am not sure exactly what to do. I am trying to create a mysql database with links so that I can obtain parent/child relationships and manipulate the data in multiple ways.
I've seen recursion, modified preorder tree traversal, and just about everything else and I really have no idea how to get this working the way I want and which method to use. I have played with all of these extensively. Here are the basic tasks I want to complete:
Be able to add pages into mysql database using a form (I know how to do this...I just need to know the mysql setup)
Be able to write a class with functions such as getParent(), getChild, and the other basic
Grab related links (or links within that section. For example, if we are under services, I would like to grab all the links that fall under the hierarchy of services so that I can display them as related links. Ideally I would like a function where I can give it the current page_id and it will develop the hierarchy from there down, with the option to ignore that page or not when it lists it.
Display #3 in an <ul> (note I have one way or another using the methods I first mentioned gotten some of these things to work, but I have never been able to get the listing to work indented using <ul>'s
A function called generateMenu() that would generate my menu in this format:
<ul id="nav" style="width: 267px;">
<li><a href="#"><img src="images/whoweare-off.jpg" width="266" height="62" border="0"
onmouseover="this.src = 'images/whoweare-on.jpg';" onmouseout="this.src = 'images/whoweare-off.jpg';" /></a>
<ul>
<li><a href="#">link 1</a></li>
<li><a href="#">link 2</a></li>
<li><a href="#">link 3</a></li>
</ul>
</li>
<li><a href="#"><img src="images/whatwedo-off.jpg" width="266" height="62" border="0"
onmouseover="this.src = 'images/whatwedo-on.jpg';" onmouseout="this.src = 'images/whatwedo-off.jpg';" /></a>
<ul>
<li><a href="#">link a</a></li>
<li><a href="#">link b</a></li>
<li><a href="#">link c</a></li>
<li><a href="#">link d</a></li>
<li><a href="#">link e</a></li>
</ul>
</li>
<li><a href="#"><img src="images/portfolio-off.jpg" width="266" height="62" border="0"
onmouseover="this.src = 'images/portfolio-on.jpg';" onmouseout="this.src = 'images/portfolio-off.jpg';" /></a>
<ul>
<li><a href="#">link A</a></li>
<li><a href="#">link B</a></li>
<ul>
<li>link 1</li>
<li>link 2</li>
</ul>
<li><a href="#">link C</a></li>
</ul>
</li>
<li><a href="#"><img src="images/casestudies-off.jpg" width="266" height="62" border="0"
onmouseover="this.src = 'images/casestudies-on.jpg';" onmouseout="this.src = 'images/casestudies-off.jpg';" /></a>
<ul>
<li><a href="#">link</a></li>
<li><a href="#">link2</a></li>
<li><a href="#">link3</a></li>
<li><a href="#">link4</a></li>
<li><a href="#">link5</a></li>
</ul>
</li>
</ul>
So basically each level is surrounded by <ul> tags.
And along with that code be able to run the onmouse overs. So if I am on page casestudies, onMouseOver and onMouseOut would both be set to casestudes-on (so it's always highlighted) and all the others would function normally.
Now I'm having trouble setting up my database and with the logic for these things. I'm not looking for someone to write this for me as the fun is all in getting it to work properly (although code examples are appreciated), I would more than anything just appreciate a bump in the right direction for writing a class to get this all working along with the database structure.
If there were only two levels I could easily accomplish this, but I am unsure of how to accomplish this with an indefinate amount of levels (speed isn't that much of an issue as I won't have hundreds of levels. Maybe 20-30 links at the most).
Sorry for the long post. I thought it might help in the planning if I included everything I'd like to accomplish upfront.
Cgraz