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
https://forums.phpfreaks.com/topic/263765-simple-breadcrumbs-for-website/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.