`<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>
I have a search page that use php and mysql data. On clicking on search button desire data gets printed in tabular form. Problem is on refreshing page that table still remains while I need whole page to get reset.
there is search bar and on pressing the search button will search tid and status details corresponding to application id entered in search.
corresponding to each tid name is fetch from another table.
both name and status are save in respective arrays and then printed in tabular format which was not there in starting but created on button click for submit by if(isset($_POST['search'])).
</div>