My code for some reason is displaying my nested lists for my tree menu all wrong can someone help me correct this problem? So that my nested lists are nested correctly for my tree menu.
Here is my PHP code.
function category_tree($parent = 0, $parent_url = ''){
echo "<ol>";
$mysqli = mysqli_connect("localhost", "root", "", "sitename");
$q = "SELECT id, category, url FROM categories WHERE parent_id = '" . $parent . "' ORDER BY category asc";
$r = mysqli_query($mysqli, $q);
while($rs = mysqli_fetch_array($r) ){
$url = $parent_url . $rs['url'];
echo '<li><a href="' . $url . '" title="' . $rs['category'] . ' Category Link">' . $rs['category'] . '</a></li>';
category_tree($rs['id'], $url);
}
mysqli_free_result($r);
echo "</ol>";
}