gterre Posted September 18, 2006 Share Posted September 18, 2006 How do i do this? according to people online i'm supposed to right click the table and select export to microsoft excel, however when I do this it says, the webquery returned no data. I'm guessing because i'm using sessions. Is there any way where i can put a link for example ..export.. and when the user clicks on it, it will export into an excel document.. I am using the PHP api.Thank you :) Link to comment https://forums.phpfreaks.com/topic/21175-export-mysql-select-query-into-excel/ Share on other sites More sharing options...
obsidian Posted September 18, 2006 Share Posted September 18, 2006 well, you can always simply generate a CSV or tab delimited file with any query results:[code]<?php$sql = mysql_query("SELECT * FROM tableName");$rc = mysql_num_rows($sql);if ($rc > 0) { // at least one row returned: header("Content-type: application/txt"); header("Content-Disposition: attachment; filename=myTabbedFile.txt"); while ($row = mysql_fetch_array($sql)) { // create row with quoted text $row = implode('\t', $row) . "\n"; echo $row; } exit(); // will keep the close of the html page being included}?>[/code]hope this helps Link to comment https://forums.phpfreaks.com/topic/21175-export-mysql-select-query-into-excel/#findComment-94155 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.