Below are 2 functions that will handle the Query and rending of the menu from MySQL Database.
This function Loops through the array. Takes in 2 arguments.
function loop_section($array, $parent_id = 0){
echo '<ul>';
foreach($array as $section){
echo '<li>';
echo $section->section_name;
echo '</li>';
}
echo '</ul>';
}
This function handles the Querying of the menu from the table section in the database.
function fetch_sections(){
global $db;
$array = array();
$query = $db->SELECT("SELECT * FROM sections");
$array = $db->ROWS();
loop_section($array);
}
At the moment when I run this, I get all the menu as the same, I mean all of them renders as first level format. What am I missing over here?