Jag hoppas fungerar:
function category_tree( $parent = 0, $parent_url = "www.example.com/" ){
echo "<ol>";
$sql = sprintf("SELECT id, category, url FROM categories where parent_id = %d order by category asc", $parent);
$r = mysql_query( $sql );
while( $rs = mysql_fetch_assoc( $r ) ){
$url = $parent_url . $rs['url'];
$item = sprintf("<li> <a href = '%s' >%s</a> </li>", $url , $rs['category']);
echo $item;
category_tree( $rs['id'], $url );
}
mysql_free_result( $r );
echo "</ol>";
}