Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/386.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在不影响php中的任何其他函数的情况下清除以前的回显结果?_Php_Javascript_Mysql_Ajax - Fatal编程技术网

如何在不影响php中的任何其他函数的情况下清除以前的回显结果?

如何在不影响php中的任何其他函数的情况下清除以前的回显结果?,php,javascript,mysql,ajax,Php,Javascript,Mysql,Ajax,我目前正在网站上工作,它有一个搜索框来搜索特定的项目。该页面以表格格式回显结果。到目前为止,一切都很完美,但当我尝试过滤结果(取决于功能)时,我得到了两组结果。一个是先前显示的结果表,另一个是过滤后的结果。我不希望以前的结果再次显示在屏幕上,而不影响任何其他过程。类似会话的东西??我不知道该如何处理这种情况 <?php include'search.php';// form for a search box. if (isset($_POST['search_na

我目前正在网站上工作,它有一个搜索框来搜索特定的项目。该页面以表格格式回显结果。到目前为止,一切都很完美,但当我尝试过滤结果(取决于功能)时,我得到了两组结果。一个是先前显示的结果表,另一个是过滤后的结果。我不希望以前的结果再次显示在屏幕上,而不影响任何其他过程。类似会话的东西??我不知道该如何处理这种情况

<?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>';
        }
    }

}

?>

请参见以下代码:

echo 'world';
echo 'hello !';
您可以使用和截获回声


由于ob“输出缓冲”是PHP固有的,因此您可以将其与函数、include等一起使用。我使用这种方法,在我的控制器流中截取(1.)输出,并截取(2.)视图的输出,以便以后编写它们(例如,将PHP错误呈现到调试分区中。

这里的代码很有用。是的,让我们看看您的代码!请提供一些代码。并使用搜索功能查看是否还有其他类似的问题。我的代码嵌套在不同的文件中,因此我编辑了所有内容的起始代码。希望它有帮助。我已经可以告诉您问题最有可能出现在您的AJAX/Javascript代码中。谢谢。我很高兴您理解了这个问题。:)我真的非常感谢您的帮助。:)是的,欢迎使用stackoverflow!请记住回答。我也会给你一些建议;)
ob_start();
echo 'world';

var $echoed = ob_get_contents();
ob_clean();

// real echo
echo 'hello ' . $echoed . '!';

// now you see
// hello world!