How do i implement a dynamic navigation in php?
e.g
Home | about | contact | faq | tutorials
i need to automatically generate the links dynamically
i agree with the first solution even if its a bit simply. For me you have to split your website into some script where you include your navigation script like the second solution.
but if you really want to make a dynamic navigation, your data cant be write in a file and they are stock in a database or on an xml file.... to do that you have to create a class or a function who parse your data and create array like first solution.
/* header.php (main header template)*/
...
and in another script you have to create a class who manage the data
';
$dataFromDataBase = $cnx->getArray('MySqlRequest');
foreach($dataFromDataBase as $menu) {
$menuList .='- '.$menu->name.'
';
}
$menuList .= '';
return $menuList;
}
}
i write it fast but i hope i can help some who look for tips to create dynamic menu.