I want to use this menu in my web page. So I include this to index.php
But everytime I click a menu and load a new page, active menu style (.active class) is gone and it turns to its initial style. So users can't figure out which page they are visiting right then.
I wonder if I can figure this out with body classes? For example, can I say "if body class is this than make that menu class active" So I could change active menu style and understand which page I am visiting.
I have 3 menu and each menu has at least 5 submenu.
<?php
$pages = array('pageA','pageB','pageC');
if (!empty($_GET['page'])) {
if(in_array($_GET['page'], $pages)) {
$page = $_GET['page'];
$id = $_GET['id']; }
else {
header("Location:error.php");
} }
else { $page='empty';}
?>
<body class = "<?php echo $page $id?>">
This is my menu structure:
<ul>
<li class="active">
<h3>pageA</h3>
<ul>
<li><a href="index.php?pageA&id=1">1</a></li>
<li><a href="index.php?pageA&id=2">2</a></li>
<li><a href="index.php?pageA&id=3">3</a></li>
<li><a href="index.php?pageA&id=4">4</a></li>
<li><a href="index.php?pageA&id=5">5</a></li>
</ul>
</li>
<li>
<h3>pageB</h3>
<ul>
<li><a href="index.php?pageB&id=1">1</a></li>
<li><a href="index.php?pageB&id=2">2</a></li>
<li><a href="index.php?pageB&id=3">3</a></li>
<li><a href="index.php?pageB&id=4">4</a></li>
<li><a href="index.php?pageB&id=5">5</a></li>
</ul>
</li>
</ul>
<body class="<?php echo $page . "_" . $id; ?>">
– GrafiCode