saludos, estoy intentando exportar datos mysql hacia un EXCEL usando php,
el problema que tengo es que cuando intento exportar los datos no se exportan, osea muestra los datos en pantalla de nuevo, pero no me da la ventana para exportar..
<?php $output = ''; if(isset($_POST["export_excel"])) { $sql = "SELECT * from tblaccounts inner join tblinvoiceitems on tblinvoiceitems.invoiceid=tblaccounts.invoiceid WHERE tblaccounts.date BETWEEN '2015-12-25 0:00:00' AND '2016-09-20 23:59:00'"; $result = mysql_query($sql);
$output .= '<table>
<tr>
<th>Transaction Date</th>
<th>Invoice Number</th>
<th>User ID</th>
<th>Company Name</th>
<th>Payment Method</th>
<th>Description (Package or Service)</th>
<th>Amount</th>
<th>Tax</th>
<th>Tax Amount</th>
<th>Total</th>
</tr>';
while ($r2 = mysql_fetch_array($result)){ echo "<tr>"; echo '<td>'.$r2["duedate"].' </td>'; echo '<td>'.$r2["invoiceid"].'</td>'; echo '<td>'.$r2["userid"].'</td>'; $r9 = mysql_fetch_array(mysql_query("SELECT * FROM tblclients WHERE id=$r2[userid]")); echo '<td>'.$r9["companyname"].'</td>'; echo '<td>'.$r2["paymentmethod"].'</td>'; echo '<td>'.$r2["description"].'</td>'; echo '<td>'.$r2["amount"].'</td>'; echo '<td>'.$r2["taxed"].'</td>'; if ($r2["taxed"] == 0 ) { $r3 = mysql_fetch_array(mysql_query("SELECT * FROM tbltax WHERE id = $r2[taxed] ")); echo "<td> no tax </td>"; echo '<td>'.$r2["amount"].'</td>'; } else { $r3 = mysql_fetch_array(mysql_query("SELECT * FROM tbltax WHERE id = $r2[taxed] ")); $r6 = $r2["amount"] / $r3["taxrate"]; $r8 = $r6 + $r2["amount"]; echo "<td> $r6 </td>"; echo "<td> $r8 </td>"; } echo " </tr>"; } $output .= '</table>'; header("Content-Type: application/xls"); header("Content-Disposition: attachment; filename=download.xls"); echo $output; } ?>
Pues el codigo lo saque de aqui: http://webslesson.blogspot.com/2016/02/export-mysql-data-to-excel-in-php-php-tutorial.html
Lo modifique un poco porque estoy usando mysql_query y no mysqli_query ..
¿alguien puede ayudarme?