PHP表中的实时搜索

PHP表中的实时搜索,php,jquery,html-table,Php,Jquery,Html Table,我创建了一个简单的搜索引擎,但我希望每当我搜索名称时,它都会按原样显示在表中。问题是其他数据会被隐藏,我不知道怎么做。 这是我的Html代码 <form name="view" method="post" div class="frm1"> <table align="center" class="record_table" > <tr bgcolor="#006600" height="50" style="color:#FFF;"> <th>

我创建了一个简单的搜索引擎,但我希望每当我搜索名称时,它都会按原样显示在表中。问题是其他数据会被隐藏,我不知道怎么做。 这是我的Html代码

<form name="view" method="post" div class="frm1">
<table align="center" class="record_table" >
<tr bgcolor="#006600" height="50" style="color:#FFF;">
  <th>&nbsp;</th>
  <th>Name</th>
  <th>Email</th>
  <th>Packages</th>
  <th>Contactno</th>
  <th>Gender</th>
  <th>File</th>
  <th>Address</th>
  <th>Action</th>
</tr>
Search:
<input type="text" size="20" name="search" onKeyup="srch();">
<div id="d1"</>
<script>
function srch()
{
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","dbsearchfile.php?view="+document.view.search.value,false);
xmlhttp.send(null);
document.getElementById("d1").innerHTML=xmlhttp.responseText;
}
</script>
这是我的PHP代码

<?php
$view=$_GET['view'];
mysql_connect("localhost","root","");
mysql_select_db("pm");
$res=mysql_query("select * from tblreservation where Name like ('$view%');");
echo "<table>";
while($row=mysql_fetch_array($res))
{
echo "<tr>";
echo "<td>";
echo "<div class=frm1>";
echo "<a href='#'>". $row['Name'] . "</a>";
echo "</td>";
echo "</tr>";
}
echo "</table>";
?>

我认为在PHP方面做起来太复杂了。我建议使用jQuery.FilterTable插件留在客户端并在那里进行过滤。您将获得一个不重新加载页面的实时搜索。但是使用Ajax可以进行重新蚀刻

插件:

演示:

请参见:

<div id="d1"</>
建议:

$res=mysql_query(" select * from tblreservation where Name like '".$view."%'; ");

您的HTML有语法错误,您所说的“按原样显示在表中”是什么意思?你是说你想在不重新加载页面的情况下根据一些搜索过滤原始表数据吗?使用“按名称”实时搜索表行。你错过了mysql\u select\u dbpm中的关闭;实时搜索表php和mysql
$res=mysql_query("select * from tblreservation where Name like ('$view%');");
$res=mysql_query(" select * from tblreservation where Name like '".$view."%'; ");