Hi all
I have a database with many sections/pages and each of these sections is assigned to a parent section in the database as follows:
sectionid | name | parent | url
The parent field is the sectionid of its parent record.
So, Services might be sectionid = 3, and a sub section of Services has it's parent field set to 3, and so on...
I have come across a problem i need help with.
On my homepage, I need to allow the admin of the site to choose out of any section in the database, to display that section as a 'quick link' on the homepage so the user can click it and be directed to that page instantly, no matter how deep in the navigation it is nested and this is where I need advice.
I have stored my sectionid, parent, name and url fields into 4 separate arrays as such:
$sections['sectionid']
$sections['name']
$sections['url']
$sections['parent']
In my 'Quick Links' function, I have the following, which I believe is where I need to do the work:
if ($count > 0) {
echo "\t\t<ul id=\"toplist\">\n";
while ($row = mysql_fetch_array($result)) {
$sectionid = $row['sectionid'];
$title = $row['name'];
$url = $row['url']; // friendly url string e.g. about-us or contact-us etc
$parent = $row['parent']; // the Parent record sectionid
// build up the list of parent URL's here and append to $url??
echo "\t\t\t<li><a class=\"notactive\" href=\"/$url\" title=\"$title\">$parent</a></li>\n";
}
mysql_free_result($result);
echo "\t\t</ul>";
}
Can somone help me out here and explain/show me how I get to recurse back through my array to get the URL's of all parent sections of the links?
I hope that makes sense I and I appreciate you reading.
Many Thanks
K