gpt4 book ai didi

php - 导航菜单 PHP ECHO INSIDE ECHO

转载 作者:行者123 更新时间:2023-11-30 00:51:16 26 4
gpt4 key购买 nike

我正在制作导航菜单,我想添加一个事件类这是我的代码

我想输出 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\""

最佳答案

请尝试以下代码

  <?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']);
}

}
?>

关于php - 导航菜单 PHP ECHO INSIDE ECHO,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20948649/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com