I have tried to search for solutions but can't find one. On my php page I am trying to search records on two conditions, if user enters something in search box then show according to that and if he doesn't searches anything then display records from table.
I am getting all records but unable to get records when i search for them using their name.
 <?php
 if(isset($_POST['search']))
 {
 $name=$_POST['src'];
 $qry1=mysqli_query($connection,"select * from test_history where 
 username='$name'");
 }
 else
 {
 $qry1=mysqli_query($connection,"select * from test_history");
 $counter=0;
 while($ftc=mysqli_fetch_array($qry1))
 echo
 '<tr>
 <td align="center"> '.++$counter.' </td> 
 <td> '.$ftc['username'].' </td>    
 <td> '.$ftc['enrollment'].' </td> 
 <td> '.$ftc['test_cat'].' </td> 
 <td> '.$ftc['test_name'].' </td> 
 <td> '.$ftc['score'].'% </td> 
 <td> '.$ftc['test_date'].' </td> </tr>';
 }
  if(isset($_POST['submit']))
  {
    $dlt=mysqli_query($connection,"delete from test_history");
  }
 ?> 
 
    