我正在制作导航菜单,我想添加一个活动的课程 这是我的代码
我想输出CSTYLE并使用' if来回显活动类
<?php
$result = mysql_query("SELECT CSTYLE,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 id="page_%s">%s %s </a></li> ', $row['CSTYLE'], $row['id'],
$row['name'],$row['DESCRIPTION']);
}
?>
这是CSTYLE的内容
if ($thisPage=="HOME") echo " class=\"active\""
答案 0 :(得分:0)
请尝试以下代码
<?php
$result = mysql_query("SELECT CSTYLE,id, name, DESCRIPTION FROM menu where VISIBLE='1'
ORDER BY `order` ASC") or die(mysql_error());
while($row = mysql_fetch_array($result)){
if (strtolower($thisPage)==strtolower($row[2])) {
printf('<li class="active" %s id="page_%s">%s %s </a></li> ', $row['CSTYLE'], $row['id'],
$row['name'],$row['DESCRIPTION']);
}
else
{
printf('<li %s id="page_%s">%s %s </a></li> ', $row['CSTYLE'], $row['id'],
$row['name'],$row['DESCRIPTION']);
}
}
?>