Been trying since yesterday and today finaly am close to achieving it.
The Problem
My PHP scripts hangs up, what I means is that it seems that it loops infinite which causing the script to hang up. In the database theirs only 11 records.
This function loops through the array of data that was passed in the function from generate_module and generates the menu and submenu
function module_keys($array = array(), $modules_parent = 0){
echo '<ul class="nav navbar-nav side-nav">';
foreach($array as $item){
echo '<li>';
echo '<a>';
echo $item->modules_name;
echo '</a>';
module_keys($array, $item->modules_id);
echo '</li>';
}
echo '</ul>';
}
This function queries the database and stores the results in the array which is then passed to module_keys to generate the menu and submenu.
function generate_module(){
global $db;
$array = array();
$sql = "SELECT * FROM module";
$query = $db->SELECT($sql);
$array = $db->ROWS();
module_keys($array, $modules_parent = 0);
}
Here is the database structure
