Hello, I have a function that is working to generate the navigation bar, it grabs the parents and the "childs" and displays them but I have noticed that it is not closing the ul, li tags properly. I will attach a screen shot below.
My code is this:
<?
include 'config.php';
function showMenu($level = 0) {
$result = mysql_query("SELECT * FROM `tbl_structure` WHERE `PARENTID` = ".$level);
echo "<ul class='nav'>";
while ($node = mysql_fetch_array($result)) {
echo "<li><a href='prodid=".$node['ID']."'>".$node['NAME'];
$hasChild = mysql_fetch_array(mysql_query("SELECT * FROM `tbl_structure` WHERE `PARENTID` = ".$node['ID'])) != null;
if ($hasChild) {
showMenu($node['ID']);
}
echo "</a></li>";
}
echo "</ul>";
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="testcss.css" rel="stylesheet" type="text/css" />
</head>
<body>
<? echo showMenu() ?>
</body>
</html>
Any help would be great!
Thanks