Imagine a database table that lists information about web pages in a parent-child relationship, like this:

Code:
URL | TITLE | PARENT
Minerals | Minerals | Topics
Minerals/USA | State Minerals | Minerals
Minerals/USA/Highlights | State Mineral Highlights | Minerals/USA
In other words, the URL MySite/Topics/Minerals is the parent of MySite/Topics/Minerals/USA, which is the parent of MySite/Topics/Minerals/USA/Highlights.

At the end of this post is a script I'm using to display bread crumbs type navigation links at the top of my page. It works, but my navigation links sometimes look something like this:

Code:
Topics > Minerals > Minerals/USA > Minerals/USA/Highlights
How can I modify the script so my navigation links look like this?:

Code:
Topics > Minerals > State Minerals > State Minerals Highlights
Of course, I need to retain the values from the field URL for the links, like this...

Code:
<a href="/Topics/">Topics</a> > <a href="/Topics/Minerals/">Minerals</a> > <a href="/Topics/Minerals/USA/">State Minerals</a> > State Minerals Highlights
Thanks.

PHP Code:
<?php
switch ($MySection)
{
 case 
'World':
 
$TopnavTable 'gw_geog';
 
$TopnavName 'Name';
 break;
 case 
'Topics':
 
$TopnavTable gs_topics;
 
$TopnavName 'URL';
 break;
 default:
 break;
}

$TopnavName str_replace('_'' '$TopnavName);

function 
get_path($node$TopnavTable$TopnavName) {
$result mysql_query('SELECT Parent FROM ' $TopnavTable ' WHERE ' $TopnavName '="'.$node.'";');
   
$row mysql_fetch_array($result);
   
$path = array();
   if (
$row['Parent']!='') {
       
$path[] = $row['Parent'];
$path array_merge(get_path($row['Parent'], $TopnavTable$TopnavName), $path);
   }
   return 
$path;
}
$mypath get_path($MyURL$TopnavTable$TopnavName);

for(
$i=0;$i<count($mypath);$i++){

switch (
$MySection)
{
 case 
'World':
 
$That = array('Earth');
 
$This = array('');
 echo 
"<a href=\"/$GWWorld".str_replace($That$This$mypath[$i])."\" title=\"$mypathD[$i]\">".str_replace('Earth''World'$mypathD[$i])."</a>&nbsp;&gt; ";
 break;
 default:
 echo 
"<a href=\"/$MySection/".str_replace(''.$MySection.''''$mypath[$i])."\" title=\"$mypathD[$i]\">".$mypathD[$i]."</a>&nbsp;&gt; ";
 break;
}

}
echo 
"\n";
?>