使用 Jquery ajax 从主页调用 search.php。确保你引用了 jQuery 库。
//Main Page
<form id="search" method="post" action="" >
<input type="text" name="search" id="search">
<input type="submit" name="search1" id="search1" class="btnButton" value="Search"/>
</form>
<div id="content"></div>
<script>
$(document).ready(function(){
//jquery click event
$("#search").live("click", function(e){
//disable default form submit postpage
e.preventDefault();
//make ajax call to the search.php parsing the search textbox value as query string
$.get("search.php?s="+$("#search").val(), function(result){
//Result will be dumped in the div
$("#content").html(result);
});
});
});
</script>
//Search PHP Script search.php
<?php
//Get the search String
$string = $_GET["s"];
//DO search query and echo it on this page.
?>