我有$ _GET数组的问题。在我的网页上,值来自像这样的URL。
http://localhost/search.php?subject=Mathematics
我检查这个$ _GET值是这样的..
// Check for a valid keyword from search input:
if ((isset($_GET['subject'])) && (is_string ($_GET['subject']))) { // From SESSION
foreach ($_GET AS $key => $subject) {
$searchKey = $key;
$searchKeyword = '%'.$subject.'%';
}
} else { // No valid keyword, kill the script.
echo 'This page has been accessed in error.';
include ('includes/footer.html');
exit();
}
现在,它为我工作。但我的问题是我使用另外两个变量来通过同一页上的URL来过滤我的数据库值。
echo '<li><a href="?tutor=link">Tutor</a></li>
<li><a href="?institute=link">Institute</a></li>';
这两个链接我用来过滤我的数据库值(点击此链接)。
$tutor = isset($_GET['institute']) ? '0' : '1';
$institute = isset($_GET['tutor']) ? '0' : '1';
我的问题是,当我在上面的链接试图过滤数据库的结果点击它总是将这个代码,而不是显示过滤结果。
} else { // No valid keyword, kill the script.
echo 'This page has been accessed in error.';
include ('includes/footer.html');
exit();
}
任何人都可以告诉我如何使用这3 $ _GET值。
为什么不是两个查询参数? '目标=导师及链接= ...'?这会减少你检查'$ _GET ['target']'是否包含有效的内容,而不是检查三个不同的$ _GET值。 – 2013-02-15 15:02:34