I want to create a search function. This page already has some details which I retrieved from DB in div. I want to when I click search button, hide that all retrieved details and show searched details. I used ajax for it. Now problem is when I click search button previous retrieved data is hidden, but not show as search results.
<form action="../PHP/searchrmvvac.php" method="post">
<div class="search hidden-xs hidden-sm">
<input type="text" placeholder="Search" id="search" name="search">
</div>
<div>
<input type="button" value="Search" id="searchrmvcom" name="searchrmvcom">
<script>
$("#searchrmvcom").click(function () {
var comname=$('#search').val();
$.ajax({
type:"post",
url:"../PHP/searchrmvvac.php",
data:{comname:comname},
success:function (data3) {
$('#rmvcomdiv').hide();
$('#ela').html(data3)
}
});
});
</script>
</div>
</form>
searchrmvvac.php
<?php
session_start();
require('../PHP/dbconnection.php');
$output=$_POST['comname'];
$sql="select * from company where company_name='$output' and activation_code=1";
$res=mysqli_query($conn,$sql);
if(mysqli_num_rows($res)>0) {
echo '
while ($row = mysqli_fetch_assoc($res)) {
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<table class="table table-striped table-bordered table-list">
<thead>
<tr>
<th>Action</th>
<th>ID</th>
<th>Registration number</th>
<th>Company Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center"><button type="submit" class="btn btn-default myButton" value="$row['/companyid/']" id="accept" name="accept">Remove</button></td>
<td>$row['/companyid/']</td>
<td>$row['/government_reg_no/']</td>
<td>$row['/company_name/']</td>
<td>$row['/email/']</td>
</tr>
</tbody>
</table>
<?php
}
';
}
?>[![enter image description here][1]][1]
line 27 is
<td align="center"><button type="submit" class="btn btn-default myButton" value="$row['/companyid/']" id="accept" name="accept">Remove</button></td>