php - CSS 类未反射(reflect)在表中

标签 php html css

我在表中有一些值,单击这些值我想设置一个特定的类并导航到某个页面。 该表如下所示:

    <?php
// Form the page file name
if($content_type == "")  {
    $content_type = "wtc";  
}
?>

<table border='0' width='250' class='navigation'>
    <tr>
        <td align='left' valign='right' class=<?php if($content_type == "wtc") echo 'active'; ?>><a href='?page=wtc'>Create WTC Server</a></td>
    </tr>
    <tr>
        <td align='left' valign='right' class=<?php if($content_type == "rap") echo 'active'; ?>><a href='?page=rap'>Create RAP</a></td>
    </tr>
    <tr>
        <td align='left' valign='right' class=<?php if($content_type == "lap") echo 'active'; ?>><a href='?page=lap'>Create LAP</a></td>
    </tr>
    <tr>
        <td align='left' valign='right' class=<?php if($content_type == "import") echo 'active'; ?>><a href='?page=import'>Import Services</a></td>
    </tr>
    <tr>
        <td align='left' valign='right' class=<?php if($content_type == "export") echo 'active'; ?>><a href='?page=export'>Export Services</a></td>
    </tr>
</table>

这里的问题是它正在导航到另一个页面,但是当它被点击时,类没有设置在值上。

请提出解决方案。提前致谢。

最佳答案

你需要先查看 page 值到 $_GET 数组中

// read page parameter (if it exists)
$content_type = @$_GET['page'];

// it's better to always sanitize a bit any user input
$content_type = htmlspecialchars($content_type);

if ($content_type == "")  {
    $content_type = "wtc";  
}

因为当您单击时,您实际上是通过查询字符串传递 page 参数

关于php - CSS 类未反射(reflect)在表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23058994/

相关文章:

javascript - 在 JavaScript 中使用数组作为名称对输入元素的值进行计数

php - 使用 PDO 替换 mysql_connect - 格式正确吗?

html - 具有 Bootstrap 动态高度的网格?

php - WooCommerce 按国家或地区限制产品下载

php echo 中的 alt 中的 Php 字符串

html - div 显示 :inline-block element 上的奇怪计算高度

css - 我似乎无法更新我的 CSS 的一部分。谁能告诉我我做错了什么?

html - 通过隐藏的溢出保持图像水平流动

php - 如何从 PHP 执行 linux 程序?

php - 如何回应查询