在DYnamic Navigation PHP上突出显示当前页面 [英] Highlight Current Page on DYnamic Navigation PHP

查看:187
本文介绍了在DYnamic Navigation PHP上突出显示当前页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从数据库获取动态导航菜单,因为我有一个CMS,所以这里是我的代码:

 < ul> ; 
<?php
$ result = mysql_query(SELECT id,name,DESCRIPTION FROM menu where VISIBLE ='1'ORDER BY`order` ASC)或die(mysql_error
while($ row = mysql_fetch_array($ result)){
printf('< li>%s%s< / a>< / li>',$ row ['name'] ,$ row ['DESCRIPTION']);
}
?>

以突出显示当前页面,我必须将其添加到li元素中

我应该怎么做呢?提前感谢。

解决方案

在页面上设置变量

  $ navlink ='< somevalue>'

li的值

 < li<?php if($ navlink =='< somevalue>'){ echoclass ='active'}?>> 

我认为它会工作。


I get my dynamic navigation menu from the database because I have a CMS, so here's my code:

<ul>
<?php
$result = mysql_query("SELECT id, name, DESCRIPTION FROM menu where VISIBLE='1' ORDER BY `order` ASC") or die(mysql_error());                   
while($row = mysql_fetch_array($result)){
printf('<li>%s %s </a></li> ', $row['name'],$row['DESCRIPTION']);
}
?>

to highlight the current page, i have to add this inside the li element

how should i do this? Thanks in advance.

解决方案

set a variable on the page like

$navlink = '<somevalue>'

and check the the value in li

<li <?php if($navlink == '<somevalue>') {echo "class='active'"}?>>

i think it will work.

这篇关于在DYnamic Navigation PHP上突出显示当前页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆