ORIGINAL POST
I want to create a navigation menu in PHP with Bootstrap 4. Problem is that one of the \'s is not right (the on
I have maked some changes for bootstrap 4.1
prepare("SELECT * FROM menu WHERE status = 1 ORDER BY position ASC");
if($sql->execute()) {
while ($row = $sql->fetch(PDO::FETCH_ASSOC)) {
$array[$row['menu_sub_id']][] = $row;
}
main_menu1($array);
}
}
function main_menu1($array, $parent_id = false) {
if(!empty($array[$parent_id])) {
foreach ($array[$parent_id] as $item) {
if ($item['dropdown'] == false) {
echo '';
}
elseif ($item['dropdown'] == true) {
echo '';
}
}
}
}
function sub_menu1($array = array(), $parent_id = false) {
if(!empty($array[$parent_id])) {
echo '";
}
}
function sub_sub_menu1($array = array(), $parent_id = false) {
if(!empty($array[$parent_id])) {
echo '";
}
}
?>
also some SQL info
CREATE TABLE `menu` (
`menu_id` int(11) NOT NULL,
`menu_sub_id` int(11) NOT NULL,
`added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`status` int(1) NOT NULL DEFAULT '1',
`href` varchar(150) NOT NULL,
`class` varchar(150) NOT NULL,
`position` int(3) NOT NULL,
`name` varchar(150) NOT NULL,
`description` varchar(500) NOT NULL,
`dropdown` int(11) NOT NULL,
`sub_menu` int(1) NOT NULL,
`sub_sub_menu` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `menu`
ADD PRIMARY KEY (`menu_id`);
ALTER TABLE `menu`
MODIFY `menu_id` int(11) NOT NULL AUTO_INCREMENT;
COMMIT;