Hi all, great forum so far. Am new so hope I find my way around ok.
I have been working on a site that uses mysql to store the info and then php to talk to mysql. Basically the site has a custom build CMS (I'm learning).
I have created a dynamic subnav in my page where entries can be added or removed in the admin area for the site.
Here is the code that pull the info etc. How can I set an active state for nav? Each sub nav link dynamically created the href.
I need to find if the url is the same as the href for each subnav link. If it is then add a class called .active to that li item only.
Hope that makes sense? any help would be great thank you,
$subnav = new DataConn; //connection to database with my classes file
$subnav->query("SELECT * FROM stock_categories ORDER BY category_order");
$currCatID = 0;
$currCatTitle = '';
$i = 1;
?>
<ul class="subnav">
<?php
while($rs_subnav = mysql_fetch_array($subnav->result))
{
if ($i == 1)
{
$currCatID = $rs_subnav['category_id'];
$currCatTitle = $rs_subnav['title'];
}
?>
<li><a href="stock-list.php?cat=<?php echo $rs_subnav['category_id']; ?>"><?php echo $rs_subnav['title']; ?></a></li>
<?php
$i++;
}
?>
</ul>