第一页有两个超链接:
<p> COE <a href="page2.php">here</a></p>
<p> SWE <a href="page2.php">here</a></p>
我想要的是:当用户点击第一个链接时,第2页应显示以下链接:
<p> academic transcript <a href="A.php">here</a></p>
当用户点击第二个链接时,page2将显示另一个链接:
<p> courses list <a href="B.php">here</a></p>
我可以这样做吗?
答案 0 :(得分:5)
您需要以某种方式将两个链接分开。您可以传递$_GET
参数,并在第二页上检查它是否已设置。
如果您编辑指向以下
的超链接<p>COE <a href="page2.php?page=A">here</a></p>
<p>SWE <a href="page2.php?page=B">here</a></p>
然后我们可以在PHP中使用$_GET
来查找您网址中参数page
的值,如下所示。评论应该或多或少地解释发生了什么。
if (!empty($_GET['page'])) {
// If that parameter is set, we can check what it's set to
switch($_GET['page']) {
case "A":
// If the value was A, we display this
echo '<p>academic transcript <a href="A.php">here</a></p>';
break;
case "B":
// If the value was B, we display this
echo '<p>courses list <a href="B.php">here</a></p>';
break;
default:
// It didn't match any of the values, you can display a default page
echo "Not a valid page";
}
} else {
// You can put whatever you want here,
// but if no values of ?page= is set, whatever is inside here will be displayed
echo "Nothing to show!";
}
答案 1 :(得分:2)
在您的主页面中添加:
panic: reflect: reflect.Value.Set using unaddressable value [recovered]
panic: reflect: reflect.Value.Set using unaddressable value [recovered]
panic: reflect: reflect.Value.Set using unaddressable value
在page2.php中添加:
<p> COE <a href="page2.php?pageA">here</a></p>
<p> SWE <a href="page2.php?pageB">here</a></p>
上面发生的是PHP检查$url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
if (strpos($url,'pageA') !== false) {
echo '<p> academic transcript <a href="A.php">here</a></p>';
} elseif (strpos($url,'pageB') !== false) {
echo '<p> courses list <a href="B.php">here</a></p>';
}
或pageA
是否作为参数传递,分别修改页面以处理任何一个事件。