Please help... am working on a form within as html page that export my SQL table to excel and download it. but i have been experience error
Anythime i click the Export to excel button it keep taking me to a new page instead of export data to excel. Below is my form and the excel.php script
Form
<form method="post" action="sites/erp/ajaxify/excel.php">
<div id="content">
<div class="col-md-4 col-md-offset-4 text-center">
<div class="form-group">
<button id="exportbtn" class="btn btn-lg btn-success btn-block"> Export to Excel </button>
</div>
</div>
</div>
</form>
and the Excel.php
if(isset($_REQUEST['tablename']) && isset($_REQUEST['keyy'])){
$tablename = use_if_sent('tablename');
$result = $ez_db->query("SELECT `firstname`, 'lastname', 'email', 'gender', 'user_group', 'phone', status' FROM 'signup'");
if(mysql_num_rows($result) > 0)
{
$output .= '
<table class="table" bordered="1">
<tr>
<th>First name</th>
<th>Lastname</th>
<th>Email</th>
<th>Gender</th>
<th>Department</th>
<th>Phone</th>
<th>Status</th>
</tr>
';
while($row = mysql_fetch_array($result))
{
$output .= '
<tr>
<td>'.$row["firstname".'</td>
<td>'.$row["lastname"].'</td>
<td>'.$row["email"].'</td>
<td>'.$row["gender"].'</td>
<td>'.$row["user_group"].'</td>
<td>'.$row["phone"].'</td>
<td>'.$row["status"].'</td>
</tr>
';
}
$output .= '</table>';
header('Content-Type: application/xls');
header('Content-Disposition: attachment; filename=download.xls');
echo $output;
}
}
?>