|
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]
|