Highlight Current Page On Dynamic Navigation Php
I get my dynamic navigation menu from the database because I have a CMS, so here's my code:
Solution 1:
u can try the following code
<?php$currentpage = $_SERVER['REQUEST_URI'];?><ul><?php$result = mysql_query("SELECT id, name, DESCRIPTION FROM menu where VISIBLE='1' ORDER BY
`order` ASC") ordie(mysql_error());
while($row = mysql_fetch_array($result))
{
?>
<li<?phpif(preg_match("/index/i", $currentpage)||($currentpage=="/")) { echo"
class='active'"; } ?>><ahref="index.php">Home</a></li><?
}
?>
instead of index you can also write $row[name] in a variable and replace /index/i with it
Post a Comment for "Highlight Current Page On Dynamic Navigation Php"