a little bit of background - i am creating a website with a breadcrumb trail showing the user's choices in navigating the site. it should look a little like this:
choice1 >> choice2 >> choice3 >> choice4
each choice is a link leading back to the page where that choice was made. when one of these links is followed, it should truncate the list to end at that page. so, considering the above list, if a user clicked on "choice3" then the list should now read:
choice1 >> choice2
so, when a user makes a choice, the code to add their choice is this:
if ($_GET['nav_name']) {
$nav = array('page' => $_SERVER['PHP_SELF'], 'choice' => $_GET['nav_name'], 'tbl' => $GLOBALS['jobTbl']);
$_SESSION['navpath'][] = $nav;
header("Location: ./choice.php");
}
so, it appends the current info to the end of the existing trail.
the code to display the list also check the current page, and will truncate the list if the user is at a page that already has an entry.
$show = "yes";
$navs;
if ($_SESSION['navpath']) {
// loop through each choice in the trail
foreach ($_SESSION['navpath'] as $nav) {
// if the current page is in the list, truncate
if ($nav['page'] == $_SERVER['PHP_SELF']) {
$show = "no";
}
// only show these items
if ($show == "yes") {
echo "<li>» <a href=\"", $nav['page'], "\">", $nav['choice'], "</a></li>";
$navs[] = $nav;
}
}
//replace the old list with the truncated ersion
unset($_SESSION['navpath']);
$_SESSION['navpath'] = $navs;
}
the problem is that the last line, replacing the session array with the new truncated one, seems to make the navpath variable disappear! without that line, the trail behaves as expected, with new items added by the first piece of code and the second piece of code [B[displays[/B] the list up to the current page. with that line in the code, $_SESSION['navpath'] is always empty. the list is not appended and is empty even before that assignment statement is executed.
anyway... i'm out of ideas.
help...
please.