php – Export MySQL to Excel-ThrowExceptions

Exception or error:

ive code seen below wich export database to excel, wich works fine, i get a XLS file i can download, this is at my own server, but when i upload to my website it doesnt seem to work the same.

Must say ive 3500 entries at the website instead of 10 entries at my local server for test.

When i load this from my website it gives me a list,. but no XLS file pops up for availble download at my local server it does,..?
Someone any idea?

$connect = mysqli_connect("$databaseHost", "$databaseUsername", "$databasePassword", "$databaseName");

$output = '';

 $query = "SELECT * FROM users";
 $result = mysqli_query($connect, $query);
 if(mysqli_num_rows($result) > 0)
  $output .= '
   <table class="table" bordered="1">  
                         <th align=left>'.$language901.'</th>  
                         <th align=left>'.$language902.'</th>  
                         <th align=left>'.$language903.'</th>  
                         <th align=left>'.$language904.'</th>  
                         <th align=left>'.$language905.'</th>  
                         <th align=left>'.$language906.'</th>  
                         <th align=left>'.$language907.'</th>  
                         <th align=left>'.$language908.'</th>  
                         <th align=left>'.$language909.'</th>  
                         <th align=left>'.$language910.'</th>  
                         <th align=left>'.$language911.'</th>  
                         <th align=left>'.$language912.'</th>  
                         <th align=left>'.$language913.'</th>  
                         <th align=left>'.$language914.'</th>  
                         <th align=left>'.$language915.'</th>  
                         <!--<th align=left>'.$language916.'</th>-->

  while($row = mysqli_fetch_array($result))
   $output .= '
                         <td align=left>'.$row["id"].'</td>  
                         <td align=left>'.$row["statuswm"].'</td>  
                         <td align=left>'.$row["datumontvangen"].'</td>  
                         <td align=left>'.$row["ontvangendoor"].'</td>  
                         <td align=left>'.$row["datumafgifte"].'</td>  
                         <td align=left>'.$row["afgegevendoor"].'</td>  
                         <td align=left>'.$row["barcode"].'</td>  
                         <td align=left>'.$row["volumestroom"].'</td>  
                         <td align=left>'.$row["fabrikant"].'</td>  
                         <td align=left>'.$row["monteur"].'</td>  
                         <td align=left>'.$row["opdrachtnummer"].'</td>  
                         <td align=left>'.$row["mijnaansluitingnmr"].'</td>  
                         <td align=left>'.$row["projectnummer"].'</td>  
                         <td align=left>'.$row["projectnaam"].'</td>  
                         <td align=left>'.$row["notitie"].'</td>  
                         <!--<td align=left>'.$row["geschiedenis"].'</td>-->

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

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *