function breadCrumb($categoryID = 0) { global $bcArray; if ($categoryID == 0) { return ""; } if (isset($bcArray[$categoryID])) { return breadCrumb($bcArray[$categoryID]->parentID) . " > " . $bcArray[$categoryID]->categoryName; } else { return ""; } }
function breadCrumb($id, $cid, $link) { global $conn; static $menu = ''; $sql = "select id,name,fid from hy_category where id={$id}"; $rs = mysql_query($sql, $conn); $row = mysql_fetch_assoc($rs); if ($id == $cid) { //递归时$id发生变化,无法判断哪个是当前栏目,所以需要$cid $menu = "<li class='current'><a href='{$link}{$row['id']}' title='{$row['name']}'>{$row['name']}</a></li>" . $menu; } else { $menu = "<li><a href='{$link}{$row['id']}' title='{$row['name']}'>{$row['name']}</a></li>" . $menu; } if ($row['fid'] != 0) { breadCrumb($row['fid'], $cid); } return $menu; }