Jump to content

Simple Breadcrumbs for website.


AibZilla

Recommended Posts

Hi, was wondering if anyone has a decent breadcrumb link that is simple and possibly step by step? I've googled php breadcrumbs and most of them I don't understand or they don't work, If anyone has personal favorites or a particularly simple way to implement breadcrumbs into a website please help me out, thanks.

Link to comment
Share on other sites

I actually sort of figured it out but now I have a specific problem.. here is some code

<?php 

require('includes/crumb-brains.php');

$crumbMonster = new Crumbs ();


$breadcrumbs = '<a href="index.php">Home<a>';

switch ($_SERVER['PHP_SELF']) {
case '/update-list.php':
	$newCrumbListLabel = $crumbMonster->GetCrumbUpListLabelByListID($_GET["listid"]);
	$breadcrumbs .= ' » '. $newCrumbListLabel;
	break;
case '/view-list.php':
	$newCrumbListLabel = $crumbMonster->GetCrumbListLabelByListID($_GET["listid"]);
	$breadcrumbs .= ' » '. $newCrumbListLabel;
	break;
case '/update-item.php': 
	$newCrumbUpItemLabel = $crumbMonster->GetCrumbUpItemLabelByItemID($_GET["itemid"]);
	$breadcrumbs .= ' » <a href="view-list.php?listid=">Items<a> » '. $newCrumbUpItemLabel;
	break;
}

echo $breadcrumbs;

?>

 

The last case ('/update-item.php') I want the <a href="view-list.php?listid="> to get my list label and post it for the breadcrumb before the $newCrumbUpItemLabel

 

Here is my functions for better understanding.

<?php

class Crumbs {
private $crumbs = array();
private $mysql;
private $database;

function __construct(){
	$this->mysql = mysql_connect('localhost','root','');
	if (!$this->mysql) {
		echo 'no connection';
		}
	$this->database = mysql_select_db('toitdoit',$this->mysql);
	}

public function GetCrumbListLabelByListID($listId) { 
	$sql = "SELECT `ListLabel` FROM `lists` WHERE `ListId` = ".$listId." LIMIT 0,30";
	$result = mysql_query($sql);
	if (!$result) {
		die('Invalid query: ' . mysql_error());
		}
	$labels = mysql_fetch_array($result, MYSQL_ASSOC);
	return $labels['ListLabel'];
	} 

public function GetCrumbUpListLabelByListID($listId) { 
	$sql = "SELECT `ListLabel` FROM `lists` WHERE `ListId` = ".$listId." LIMIT 0,30";
	$result = mysql_query($sql);
	if (!$result) {
		die('Invalid query: ' . mysql_error());
		}
	$labels = mysql_fetch_array($result, MYSQL_ASSOC);
	return $labels['ListLabel'];
	} 

public function GetCrumbUpItemLabelByItemID($itemId) { 
	$sql = "SELECT `ItemLabel` FROM `items` WHERE `ItemId` = ".$itemId." LIMIT 0,30";
	$result = mysql_query($sql);
	if (!$result) {
		die('Invalid query: ' . mysql_error());
		}
	$labels = mysql_fetch_array($result, MYSQL_ASSOC);
	return $labels['ItemLabel'];
	} 

	}

?>

 

Thanks in advance if you can help.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.