我在表中有一些值,单击这些值我想设置一个特定的类并导航到某个页面。 该表如下所示:
<?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/