Instead of reporting the data from the database and showing it in excel , it shows in excel what's on the screen .. I would like it to show what's contained in the $excel variable .. below is my code
if(isset($_POST['excel_report'])){
$select_query = "SELECT * FROM question_data";
$result = mysql_query($select_query);
$excel ='';
$excel .= "<table border ='0'>";
$excel .= "<tr> <td> Question Title </td> <td> Question Answer </td> </tr>";
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$excel .="<tr> <td>".$row['question_title']."</td> <td>".$row['question_response']."</tr>";
}
$excel .="</table>";
$filename ="questiondata.xls";
header('Content-type: application/ms-excel');
header('Content-Disposition: attachment; filename='.$filename);
echo $excel;
}
my HTML form , for the form , the elements are dynamically added with jquery .. I'm not using any of the form data though , I am just using the submit button for excel to get the data from the database and display it on a spreadsheet .. where did I go wrong ?
<form action="/cms/form_test.php" method="post">
<h1> Test Form </h1>
<div class="test">
<input type ="hidden" name ="form_id" value ="4" />
<div id ="select_data">
<select id="select"> </select> <br /><br />
</div>
<div id ="options"></div>
<div id ="select_state">
<div id ="state_title"> </div>
<select id="select_state_dropdown"> </select> <br /><br />
</div>
</div>
<input type="submit" name ="excel_report" value="Export Question Data to Excel" />
<input type="submit" name ="submit" value="submit form" />
</form>