`<html>
<form method="post" autocomplete="off">
<input type="text" name="valueToSearch" class="search">
<input type="submit" name="search" value="Serch" class="button">
</form>
<?php
$tnam=[];
$stat=[];
$i=-1;
if(isset($_POST['search']))
{
$appId = $_POST['valueToSearch'];
$queryc="select tid,status from link where appId ='".$appId."'";
$res=mysqli_query($con,$queryc);
while($row=mysqli_fetch_array($res))
{
$i=$i+1;
$queryr="select name from admin where id='".$row['tid']."'";
$ans=mysqli_query($con,$queryr);
$r=mysqli_fetch_array($ans);
$stat[$i]=$row['status'];
$tnam[$i]=$r['name'];
}
echo "<center><div id='tabl'>";
echo "<table>";
if($i>=0)
{
echo "<tr>";
for($j=0;$j<=$i;$j++)
echo "<th>".$tnam[$j]."</th>";
echo"</tr>";
for($j=0;$j<=$i;$j++)
echo "<td>".$stat[$j]."</td>";
echo "</tr>";
}
echo "</table>";
echo "</div></center>";
$appId="";
$tnam=null;
$stat=null;
}
?>
</html>
我有一个使用php和mysql数据的搜索页面 . 点击搜索按钮时,欲望数据以表格形式打印 . 问题在于刷新页面,当我需要整页重置时,表仍然存在 .
有搜索栏,按下搜索按钮将搜索与搜索中输入的应用程序ID相对应的tid和状态详细信息 .
对应于每个tid名称是从另一个表中获取 .
名称和状态都保存在相应的数组中,然后以表格格式打印,这些格式在启动时不存在,但是在按钮点击时创建if(isset($ _ POST ['search'])) .