RE: [PHP-DB] HELP: Eporting data from mySQL with PHP

From: Date: Fri, 30 Mar 2001 18:11:11 +0000
Subject: RE: [PHP-DB] HELP: Eporting data from mySQL with PHP
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-8043@lists.php.net to get a copy of this message
> Hello, > > I'm trying to figure out how to get the data out of a table in a format > which I can easily import into excel. I wanted to have tab delimited fields > enclosed by quotes. I'm not sure how to do this? I check the mySQL doc and > saw the mysqldump call but haven't found any mention of it in the PHP doc. > > Any thoughts? code snippets? > > Thanks in Advance, > > Mark Rosenberg > Michigan State First you need this header: header("Content-Type: application/vnd.ms-excel"); Then here is a message I got a while ago from Pierre-Yves Lemaire: Hello, The header will make netscape offer you a download of the file, and IE will open it in a excell format. For the display, just put your result in a nice html table and excell will convert it, it's quite simple. print "<table>"; print "<th>Event</th>"; ... print all your header here while ($row = mysql_fetch_array($result)) { print "<tr>\n"; print "<td>". $row['Event'] ."</td>\n"; and so on... } </table> hope it help, py

« previous php.db (#8043) next »