Posting my first question on this site.
I made a php webpage where the textbox will accept search keyword and when submitted, the row of that table will be displayed. Simple!
The catch is, Rrght now, before search, the whole table is displayed already on my php page. I don't want that. I want only the result after search, The table should not be displayed before searching (the test data table have 500 rows, but the actual table will have 15,000 rows).
The page (before search):
<?php
if(isset($_REQUEST['submit'])){
$name=$_POST['name'];
$email=$_POST['email'];
$sql=" SELECT * FROM live_table WHERE name like '%".$name."%' AND company LIKE '%".$email."%'";
$q=mysqli_query($con, $sql);
}
else{
$sql="SELECT * FROM live_table";
$q=mysqli_query($con, $sql);
}
?>
<form method="post" class="search">
<table width="200">
<tr>
<td></td>
<td><input class="form__input" type="search" autocomplete="off" name="name" placeholder="Name" value="<?php if(isset($name)) echo $name;?>" /></td>
<td></td>
<td><input class="form__input" autocomplete="off" type="search" name="email" placeholder="Company Name" value="<?php if(isset($email)) echo $email;?>" /></td>
<td><input type="submit" name="submit" value=" Find " class="button"/></td>
</tr>
</table>
</form>
<table width="70%" cellpadding="5" cellspace="5" style="margin: 3em 3em 3em 3em;">
<tr>
<td><strong>Salutation</strong></td>
<td><strong>First Name</strong></td>
<td><strong>Middle Name</strong></td>
<td><strong>Last Name</strong></td>
</tr>
<?php
while($res=mysqli_fetch_array($q)){
?>
<tr>
<td><?php echo $res['id'];?></td>
<td><?php echo $res['name'];?></td>
<td><?php echo $res['company'];?></td>
<td><?php echo $res['zip'];?></td>
<td><?php echo $res['city'];?></td>
</tr>
<?php } ?>
</table>