sports-arena-website / filter5.php
filter5.php
Raw
<?php  
 //filter.php  
 if(isset($_POST["from_date"], $_POST["to_date"]))  
 {  
      include("conn.php");
      $output = '';      

      $query = "SELECT i.Item_ID, i.Item_Name, i.Item_Price, SUM(wid.Sal_Amount) FROM walk_in_sales_details wid, walk_in_sales wis, item i WHERE (wid.Sal_ID = wis.Sal_ID) AND (wid.Item_ID = i.Item_ID) AND (wis.Sal_Date BETWEEN '".$_POST["from_date"]."' AND '".$_POST["to_date"]."') GROUP BY i.Item_ID ";
      $result = mysqli_query($conn, $query);  
      $output .= '  
          <h3 style="color:orange;margin-top:15px;">Walk In Sales</h3> 
          <table class="table">
               <thead class="thead-dark">
                    <tr>
                        <th>Item ID</th>
                        <th>Item Name</th>
                        <th>Price</th>
                        <th>Walk-In Sold</th>
                        <th>Total Revenue</th>
                    </tr>
               </thead>  
     ';  
     if(mysqli_num_rows($result) > 0)  
     {  
          while($row = mysqli_fetch_array($result))  
          {  
               $output .= '  
                    <tbody>
                        <tr>
                            <td>'. $row["Item_ID"] .'</td>
                            <td>'. $row["Item_Name"] .'</td>
                            <td>RM '. $row["Item_Price"] .'</td>
                            <td>'. $row["SUM(wid.Sal_Amount)"] .'</td>
                            <td>RM '. $row["Item_Price"] * $row["SUM(wid.Sal_Amount)"] .'</td>
                        </tr>
                    </tbody> 
               ';  
          }  
     }  
     else  
     {  
          $output .= '  
               <tr>  
                    <td colspan="5">No Items Sold Walk In Found!</td>  
               </tr>  
          ';  
     }  
     $output .= '</table>';  
     echo $output;  
}  
?>