You are here: Re: I have sub-categories but want to display full category path « PHP Programming Language « IT news, forums, messages
Re: I have sub-categories but want to display full category path

Posted by Phil Latio on 02/04/07 15:50

Geoff

Based on your model I came up with the following. It uses Jason Gilmore's
MySQL connection class from his book "Beginning PHP5 and MySQL" published by
Apress.

I am quite pleased with this as I managed to get rid of the trailing >>
which looked very untidy.

What I shall eventually do is turn it into a class.

Thanks for your help

Cheers

Phil

<?php

require 'class.MySQL.php';
$link_id = 4;
breadcrumb($link_id);

function breadcrumb ($object)
{

while($object >0)
{
$db=new MySQL("*****", "*****", "*****", "***");
$db->connect();
$db->select();
$db->query("SELECT category_name,parent_category_id from category where
category_id=$object");
$result=$db->fetchArray();
$breadcrumb_array[] = $result[category_name];
$object = $result[parent_category_id];
$counter ++;
}

print $breadcrumb_array[$counter];
$counter --;
while ($counter >0)
{
print $breadcrumb_array[$counter];
print ">> ";
$counter --;
}
print $breadcrumb_array[0];
}
?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация