I've started to code a health site that will have a "directory" type structure, such as the one below
Home > Training > Muscle Groups > Upper Body Muscle Groups > Chest Muscles
Then there will be a list of articles that are under "chest muscles".
Now, I have been successfull so far to this point:
http://72.29.66.47/~nick/startupfitness/index.php?id=6
If you click that link, then you will see my table structure outputted for reference, and then below it, an array printed out using print_r();
Now, what happens is, i have a function called make_breadcrumbs(); for which the code is:
Code: Select all
function make_breadcrumbs( $children, $id, $dump )
{
$dump[] = $children[$id]['id'];
if( $children[$id]['parentid'] == 0 )
{
return $dump;
}
return make_breadcrumbs( $children, $children[$id]['parentid'], $dump );
};Code: Select all
//
$breadcrumb = make_breadcrumbs( $tmp, $_GET['id'], array() );
$breadcrumb = array_reverse( $breadcrumb );
// print a dump of the array, to see if it worked
echo( '<pre>' ); print_r( $breadcrumb ); echo( '</pre>' );
//output trail (path)
for( $a = 0; $a < sizeof( $breadcrumb ) -1; $a++ ) {
$id = $breadcrumb[$a]['id'];
$name = $breadcrumb[$a]['name'];
?>
<a href="www.yourdomain.com?id=<?php echo( $id ); ?>"><?php echo( $name ); ?></a> ><?php
}
echo( $breadcrumb[$a]['name'] );Code: Select all
$breadcrumb[$a]['name']Code: Select all
$breadcrumb[$a]['id']Anyone have idea?
btw. my first post w00t