Page 1 of 1

[SOLVED] Adjacency List Method Troubles

Posted: Mon Sep 05, 2005 10:48 am
by n_karpov
Hey guys,

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 );
};
and in my actual index.php i have the following code:

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'] );
Now the problem is that the breadcrumb output ei.

Code: Select all

$breadcrumb[$a]['name']
outputs 1 letter, of the name and even if i do

Code: Select all

$breadcrumb[$a]['id']
it still outputs just the first letter of the NAME field. So this has me running in circles trying to figure out whats wrong, it cant be the function, becuase if i do print_r($breadcrumbs); then it displays the array fine.

Anyone have idea?

btw. my first post w00t :D

Posted: Mon Sep 05, 2005 10:55 am
by n_karpov
quite redundant, and im really sorry, but someone has already pointed out my mistake, err. [SOLVED] then :P sorry bout that 8)