Help with navigation history



I have the following table for category/sub category :

CategoryID - int
Title - varchar
MainCatID - int

CategoryID | Title | MainCatID
------------- --------- -----------------
1 | News | 1
2 | Sports | 1
3 | Local | 2

On my site, I want to display a navigation history at the top of the page, when the user browses through the cat/subcat.

For example if i have reached the Local page, the navigation should display :

Home > News > Sports > Local

Any idea of a code how i can do this loop. Bear in mind that each time i load the page i can get the CategoryID of the page i am in.

Thanks for any help.

Devgirl. :)
I found this somewhere on the internet. I´ve never used it, but seems nice! You´ll have to change it for your needs!
/* prints a navigation bar. links to all php files. current file is
   not linked. */

# read directory
$d = dir("");
echo "<p align=\"center\"> | \n";
while($entry = $d->read()){
        // ignone non-files
        if ( !is_file($entry) )
        /* split the filename into name and extension. is a regex special character. so we escape it as \. */
        list($filenm, $fileext) = split("\.",$entry, 2);
        // ignore non-php files
        if( $fileext != "php" )
        /* no we have *only* php files. we will search for the line
        $title="something"; and split the content of the title,
        use it in the link */
        $linknm = "";
        while($buffer=fgets($fp, 4096)){
                $buffer = trim($buffer);
                // we know that all our files have the title set at the top
                // easy to search. will cause big problems if you change
                // the name of that variable...
                if (ereg("title *= *\"", $buffer)){
                        /* we have that title assignment. we take that string,
                            evaluate it. so it executes as PHP code, executing
                            $title = "blah blah" */
                        // and we copy title to linknm!
                        $linknm = $title;
        if ( $entry == basename($PHP_SELF) )
                echo  "$linknm";
                echo "<a href=\"$entry\">$linknm</a>";
        echo " | ";
echo " </p>\n";
Devgirl, you're talking about what are commonly referred to as "breadcrumbs". Google will lead you to a number of tutorials concerning breadcrumbs in PHP.
hi swirlee!

Thanks for the tip about "breadcrumbs".

I search round google and found some nice code how it is done, but all the example i have found display the breadcrumb navigation in the form directory/sub directory/sub sub directory.

In other words the code breaks down directory path to the file.

I need a code or pseudo code how i could do it from fetching data from a DB where you have category/sub category/sub sub category etc...

Thanks for any help.