Hello, there is a plugin of the three-level menu. I want to implement it in php, it does not work. I have a Catalog table with the fields id, parent, name. I could only do a two-level process, but I cannot register the third cycle, recursion is also not solved here, because it does not prescribe the correct location of tags
$tree_res = mysql_query("SELECT * FROM catalog WHERE parent= '0' AND checked='1' ORDER BY name"); while($menu_tree = mysql_fetch_assoc($tree_res)) { ?> <li><a href="/catview.php?id=<?php echo $menu_tree['id'] ?>"><?php echo $menu_tree['name'] ?></a> <?php $sub_tree_res = mysql_query("SELECT * FROM catalog WHERE parent= ' ".$menu_tree['id']." ' AND checked='1' ORDER BY name "); if (!empty($sub_tree_res)) { ?> <ul> <?php while($sub_menu_tree = mysql_fetch_assoc($sub_tree_res)) { ?> <li><a href="/catalogview.php?id=<?php echo $sub_menu_tree['id'] ?>"><?php echo $sub_menu_tree['name']; $res = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM tovar WHERE Subdivision='$sub_menu_tree[id]' and checked='1'")); echo " <b>($res[0])</b>"; ?></a></li> <?php } ?></ul> <?php } } ?> </ul>