現在、特定のアイテムを検索するための検索ボックスがある Web サイトに取り組んでいます。このページは結果を表形式でエコーアウトします。これまでのところ、すべてが完全に機能していますが、(機能に応じて) 結果をフィルタリングしようとすると、2 つの結果セットが得られます。1 つは以前に表示された結果テーブルで、もう 1 つはフィルター処理された結果です。他の手順に影響を与えずに、以前の結果を画面に再度表示したくありません。セッションみたいなもの??この状況に対処する方法が正確にはわかりません。
<?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>';
}
}
}
?>