Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function breadcrumb($id, $cat, $ext = null) {
- $s = "SELECT * FROM category WHERE (id = $id)";
- $r = mysql_query($s);
- $row = mysql_fetch_array($r);
- if($row['parent_id'] == 0) {
- $id = $row['id'];
- $name = $row['name'];
- if(!empty($except) && $ext == $row['id']) {
- return "Home";
- }
- return "Home » ".$name."";
- }
- else {
- if(!empty($ext) && $ext == $row['id']) {
- $id = $row['id'];
- $name = $row['name'];
- return breadcrumb($row['parent_id'],$cat_tbl, false). " $name";
- }
- $name = $row['name'];
- return breadcrumb($row['parent_id'],$cat_tbl, false). "» ".$name."";
- }
- }
- =======================
- Here is a simple function for breadcrumbs.
- In this example the database would have id, parent_id, and name. So an example table with data would look like the following:
- 1 0 root1
- 2 0 root2
- 3 1 subforroot1
- 4 3 subforid3
- The parent_id as 0 is the root location. Anything else is a sub folder of some sort.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement