

<?php include ("inc/config.php");
 
if(isset($_REQUEST["term"])){  $sql = "SELECT * FROM orders where released = 0 and customer  LIKE ?";
    
if($stmt = $mysqli->prepare($sql)){
 // Bind variables to the prepared statement as parameters
 $stmt->bind_param("s", $param_term);
 // Set parameters
 $param_term = $_REQUEST["term"] . '%' ;
 // Attempt to execute the prepared statement
 if($stmt->execute()){
   $result = $stmt->get_result();
   // Check number of rows in the result set
 if($result->num_rows > 0){

   echo "<table >";
   echo "<thead>";
   echo "<tr class='t1'>";
   echo "<th>Customer Name</th>";
   echo "<th>Phone no</th>";
   echo "<th>Residence</th>";
   echo "<th>Delivery Point</th>";
  echo "<th>Amount</th>";
   echo "<th>Payment mode</th>";
   echo "<th>Receipt No</th>";
   echo "<th>Time</th>";
     echo "</tr>";
   echo "</thead>";
   echo "<tbody>";
 // Fetch result rows as an associative array
 while($row = $result->fetch_array(MYSQLI_ASSOC)){
   echo "<tr>";
  echo "<td>" . $row['customer'] . "</td>";
   echo "<td>" . $row['phone'] . "</td>";   
   echo "<td>" . $row['residence']. "</td>";
   echo "<td>" . $row['delivery_point']. "</td>";
   echo "<td>" . $row['amount'] . "</td>";
   echo "<td>" . $row['mode'] . "</td>";


//   echo "<td> <a href=''> " . $row['receipt_no'] . " </a></td>";

echo
  "<td>
<form method ='post'> 
<input type='hidden' name='receipt_no' value=".$row['receipt_no']." />
<button class='receipt' type='submit' name='submit'  ><u> " . $row['receipt_no'] . " </u></button>
</form>
  </td>";

  // echo "<td>" . $row['session'] . "</td>";
  echo "<td>" . date_format( new DateTime ($row['time'] ),"d M, Y H: m: s"). "</td>";



 echo "</tr>";
         }
    echo "</tbody>";                            
    echo "</table>";
      } else{
                echo "<p class='no-results'>No matches found</p>";
            }
        } else{
            echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
        }
    }
     
    // Close statement
    $stmt->close();
}
 
// Close connection
$mysqli->close();
?>