vendredi 16 juillet 2021

Can't download excel file from php

My index page is working and it alerts when no checkbox is checked but my download button to excel won't function. What might be the problem with this? Any tips on how to solve this one? Not fully understand the checkbox functioning, anyone can help me?

<?php  
//export.php  
require_once "connection.php";
$output = '';

if(isset($_POST["id"]))
{
  foreach($_POST["id"] as $id)
  {
    $query = "SELECT * FROM allowance WHERE id = '".$id."'";
    $result = mysqli_query($connect, $query);

    if(mysqli_num_rows($result) > 0)
    {
      $output .= '
      <table class="table" bordered="1">  
                    <tr>  
                      <th>Name</th>
                      <th>Scholarship Program</th>
                      <th>Course</th>
                      <th>Semester</th>
                      <th>Status</th>
                    </tr>
      ';

      while($row = mysqli_fetch_array($result))
      {
          $output .= '
          <tr>  
                         <td>'.$row["Name"].'</td>  Name
                         <td>'.$row["Scholarship Program"].'</td>  
                         <td>'.$row["Course"].'</td>  
                         <td>'.$row["Semester"].'</td>  
                         <td>'.$row["Status"].'</td>
          </tr>
          ';
      }

      $output .= '</table>';
      header('Content-Type: application/xls');
      header('Content-Disposition: attachment; filename=download.xls');
      echo $output;
    }
  }
}
?>



Aucun commentaire:

Enregistrer un commentaire