Like I said It runs fine if I replace $output with echo, but if I just return $output it only appears to go over the loop once.
Brain has hit a dead spot and i've been fiddling with it for hours now with varying results, none of which work :s
Any pointers guys?
Code: Select all
function rebuild_links($x = 0, $tmp) {
$mysql = new MySql();
$result = $mysql->query("SELECT * FROM menu_tree WHERE template='".$tmp."' AND parent_id= '".$x."' ORDER BY homepage DESC, sortorder ASC");
if($result->num_rows() > 0) {
$output .= "\n <ul>\n";
while($result->next()) {
$output .= ' <li><a href="index.php?fn='.$result->row['filename'].'&pid='.$result->row['id'].'">'.$result->row['menu_name'].'</a>';
rebuild_links($result->row['id'], $tmp);
$output .= "</li>\n";
}
$output .= " </ul>";
}
return $output;
$mysql->close($result);
}Code: Select all
$output = rebuild_links(0, ''.TEMPLATE_NAME.'');
$fp = @fopen('../templates/'.TEMPLATE_NAME.'/navigation.php', 'w');
if (!$fp) {
echo 'Well bugger me sensless and call me mary! something wrong happend.';
}
fwrite($fp, $output);
fclose($fp);