我试图使用IF/ELSEIF命令显示信息
我的页面顶部有A到Z,我想显示一个表格,表格中的所有结果都以每个字母开头
例如,我有
<a href='?a'>A</a>
<?php
if($_GET == a)
{
echo "<table><tr><th>[picture]</th><th>information</th></tr>";
}
?>
我想显示一个包含所有信息的表,我将如何使用IF/ELSE命令来实现这一点?有没有更好的方法来做到这一点,而不去另一页?
提前感谢您的帮助
发布于 2016-02-24 18:49:15
我认为在这里使用一个开关箱比用一个更干净的开关箱更容易,而不是更干净。
首先,尝试将链接更改为如下所示:
<a href='?l=a'>A</a>
和
<a href='?l=b'>B</a>
然后,您应该尝试使用以下内容访问所选的字母:
<?php
$sLetter = null;
if (isset($_GET['l'])) {
$sLetter = strtolower($_GET['l']);
}
switch ($sLetter) {
case 'a':
echo "Information related to A";
break;
case 'b':
echo "Information related to B";
break;
// Continue in a similar way for the remaining letters
default:
echo "No information..."; // or perhaps show all A-Z information
break;
}
注意:为了测试目的,这是可以的。但是,应该始终对超球体进行验证和净化,以使您的应用程序更加安全。
https://stackoverflow.com/questions/35617054
复制相似问题