breadcrumb page from category

Hi i have a breadbrumb system working for my category’s and sub category’s using this code

$result = mysql_query("SELECT * FROM cats WHERE name='{$_GET['category']}'");
$info = mysql_fetch_array($result);
$str = $info['name'];

while ($info['parent_id'] != 0) {
$info = mysql_fetch_array(mysql_query("SELECT * FROM cats WHERE id='".$info['parent_id']."'"));
$str = $info['name']." > " .$str ;

echo "<p><a href="index.php">Home</a>";
if (isset($str)) { echo " > $str </p>"; } else echo "</p> "; 

here is my table scheme for my category’s table

`cats` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(30) NOT NULL default '',
  `parent_id` int(11) NOT NULL default '0',
  PRIMARY KEY  (`id`)

and this is my table scheme for my tutorials

tutorials` (
  `tutorialID` int(4) NOT NULL auto_increment,
  `tutorialTitle` varchar(255) NOT NULL default '',
  `tutorialDesc` text,
  `tutorialCont` text,
  `category` varchar(40) NOT NULL default '',
  `tutorialDate` timestamp NOT NULL default CURRENT_TIMESTAMP,
  `tutorialviews` varchar(30) NOT NULL default '0',
  PRIMARY KEY  (`tutorialID`)

What i’d like is some advice how I would include pages into the breadcrumb

for example as the code stands i can navigate to home > windows xp > email >
but as soon as i click on a tutorial i lose the breadcrumb and just see home > as that part is static.

I know i need to change how the code is laid out but not sure what i need to do any advice would be very useful


i’m not sure if i undersode u. how about:

elseif(isset($_GET[‘tutorialID’]){/get the category from the db/}

Not sure that will work,

let me try to explain it better

i have 2 tables cats and tutorials

the cats table is my category’s and the tutorials table is my actual pages

my breadcrumb works fine for the category’s it breakdown when i enter a page as its outside of the category i need to relate the pages to the category its in for the breadcrumb.

hmm not sure this sounds any clearer…

what i basically need to a breadcrumb that starts from the root and follows the user through the category’s and also the pages do you know how most people do this?

if i understand u every page (tutorial) has one category.
i don’t realy know what the varchar category is for. but u should ad a foreign key catID to the tutorial table. Then the solution i provided would work.

‘SELECT catID FROM tutorial WHERE tutorialID=’.intval($_GET[‘tutorialID’])

if im totaly wrong please give me some mor information.

Thanks i’ll give it a try and let you know.

Sponsor our Newsletter | Privacy Policy | Terms of Service