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 :) Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.