I wrote a function to write a "cookie trail" string w/ links for my admin page and it works GREAT. However, when I call it a second time (I want the cookie trail on the page twice), it appends the static value instead of starting a new one. I tried to reset it like this:
//-- FUNCTION THAT WILL PRINT THE COOKIE TRAIL OF CATEGORIES --//
function categoryCookieTrail($parent_category_id, $query_pass, $list_begin, $list_resort, $list_order, $carryover) {
if($carryover == "CLEAR") {
unset($cookie_trail);
$cookie_trail = "";
}
static $cookie_trail;
$category_search_query = "SELECT category_parent_id, category_title FROM categories WHERE category_id='".$parent_category_id."'";
//echo "<p><strong>category_search_query</strong>: ".$category_search_query."</p>\n";
$category_search_result = @mysql_query($category_search_query) OR die ("Couldn't complete this MySQL query: ".$category_search_query."<br />\n<br />\nError: ".mysql_error());
$category = mysql_fetch_array($category_search_result);
if(mysql_num_rows($category_search_result) > 0) {
if($cookie_trail != "") {
$cookie_trail = " > ".$cookie_trail;
}
$cookie_trail = "<a title=\"".$category["category_title"]."\" href=\"?list_begin=".$list_begin.$query_pass."&list_resort=".$list_resort."&list_order=".$list_order."&sub_category_id=".$category["category_parent_id"]."#results\">".$category["category_title"]."</a>".$cookie_trail;
categoryCookieTrail($category["category_parent_id"], $query_pass, $list_begin, $list_resort, $list_order, "CARRY OVER");
}
return $cookie_trail;
}
Can anyone out there see what I have wrong?
Thanks,
Shaun