In my main.php I have this doc declaration at the top:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Later in main.php I use code from excel.php
case 'Export to Excel':
require 'excel.php';
break;
This is excel.php:
<?php
// export to csv file the table bmbookmark and call it bookmarks.csv
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename=bookmarks.csv");
$result = mysql_query("
SELECT bmcat.title, bmbookmark.title, bmbookmark.url,
bmbookmark.order,
bmbookmark.comment, bmbookmark.private, bmbookmark.hot
FROM bmbookmark
JOIN bmcat on bmbookmark.cat_id = bmcat.id
ORDER BY bmcat.title, bmbookmark.title
");
while($row = mysql_fetch_row($result)){
print implode(",", $row)."\n";
};
mysql_free_result($result);
exit();
?>
When I export to Excel, the csv file that is created has at the top:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
I have to manually remove this doc declaration for the csv file to
behave the way it should.
What am I doing wrong? Why is this doc declaration printed in the csv
file?
Regards,
Jan Nordgreen
---
My diary:
http://jansdiary.simpler-solutions.net
Seductive math problems for the modern mind:
http://thinkagain.simpler-solutions.net
Tools for better schools:
http://moderntimes.simpler-solutions.net
What I read:
http://www.bloglines.com/public/damezumari
Mathematical ulterior motives:
http://mumnet.tripod.com