I am trying to generate breadcrumbs for users who travel through my site so they can step back if they want or have clicked on a link they did not want.
Example of what I am trying to do!
I have a home page displaying categories from my db
Music
Video
DVD
Once clicked (say music) it will take you to another page where the sub categories are displayed
What I want php to do is display the breadcrumbs
Home >> Music >> POP >> Artist
It seems easy to do with static pages and directories but not when the pages are dynamically generated using just the one page.
Can anyone help or suggest anything better
Thanks
Mark
The script I have been using is below from http://www.evolt.org/article/Breadcrumbs_for_PHP_Lovers/17/4455/
INCLUDE FILE
<?php
function breadCrumb($PATH_INFO) {
global $page_title, $root_url;
// Remove these comments if you like, but only distribute
// commented versions.
// Replace all instances of with a space
$PATH_INFO = str_replace("", " ", $PATH_INFO);
// split up the path at each slash
$pathArray = explode("/",$PATH_INFO);
// Initialize variable and add link to home page
if(!isset($root_url)) { $root_url=""; }
$breadCrumbHTML = '<a href="'.$root_url.'/" title="Home Page">Home</a> > ';
// initialize newTrail
$newTrail = $root_url."/";
// starting for loop at 1 to remove root
for($a=1;$a<count($pathArray)-1;$a++) {
// capitalize the first letter of each word in the section name
$crumbDisplayName = ucwords($pathArray[$a]);
// rebuild the navigation path
$newTrail .= $pathArray[$a].'/';
// build the HTML for the breadcrumb trail
$breadCrumbHTML .= '<a href="'.$newTrail.'">'.$crumbDisplayName.'</a> > ';
}
// Add the current page
if(!isset($page_title)) { $page_title = "Current Page"; }
$breadCrumbHTML .= '<strong>'.$page_title.'</strong>';
// print the generated HTML
print($breadCrumbHTML);
// return success (not necessary, but maybe the
// user wants to test its success?
return true;
}
?>
INCLUDE THE FILE IN THE PAGE
<?php $page_title = "";
include('/includes/breadcrumb.php'); ?>
<title><?php echo $page_title ?></title>
AND USE THE FUNCTION IN THE PAGE
<?php breadCrumb($PATH_INFO); ?>