我目前正在网站上工作,它有一个搜索框来搜索特定项目。该页面以表格格式回显结果。到目前为止一切正常,但是当我尝试过滤结果(取决于功能)时,我得到了两组结果。一个是之前显示的结果表,另一个是过滤后的结果。我不希望以前的结果在不影响任何其他程序的情况下再次显示在屏幕上。像会话之类的东西?我不知道如何处理这种情况。
<?php
include'search.php';// form for a search box.
if (isset($_POST['search_name'])) {
$search_name=mysql_real_escape_string(htmlentities(trim($_POST['search_name'])));
$errors = array();
if (empty($search_name)){
$errors[] ='please enter a search term';
}
else if (strlen($search_name)<3){
$errors[] = 'your search term must be three or more characters';
}
else if (1==2){
$errors[] ='your search for '.$search_name.' returened no results';
}
if (empty($errors)){
filter($search_name); //it display another form in the navigation bar to filter the search result.
search_results($search_name);//searches for all the result onthe database depending on the keyword entered in searchbox.
} else{
foreach($errors as $error) {
echo $error,'</br>';
}
}
}
?>