Chris Wilson - 2009-03-03 22:59:08
Hello,
I'm hoping someone can help me here.
My problem is this:
I've performed a very simple SQL query, and structured it in a table. at the end of the table I have the option to export the table to excel.
the code for the link is <a href="display.php?export=excel">export to excel</a>
within this page the first line of code is:
<?php
$sExport = @$HTTP_GET_VARS["export"];
if ($sExport == "excel") {
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment; filename=Load.xls');
}
This works FINE - but I have another variable that I pass using GET to determine how to query the database, and populate the table. this code is directly below:
if($_GET['export'] == "nsls"){
//query database based on NSLS sources
db_connect(nsls);
} else if($_GET['export'] == "ms1") {
//query database based on ms1 sources
db_connect(ms1);
} else if($_GET['export'] == "ms2") {
//query database based on ms2 sources
db_connect(ms2);
}
the called function is what determines the contents of the table...
without this code, the export works fine, opening in excel the appropriate data table. as soon as I add this code, my excel document is just a copy of the web page this is on...
What am I missing??
Please let me know if you have any suggestions, or let me know if you need more input.
Thanks very much in advance!