Re: exporting data
| From: | M.E. Suliman | Date: | Sun, 20 Apr 2003 08:16:48 +0000 |
| Subject: | Re: exporting data | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-144524@lists.php.net to get a copy of this message | ||
Hi Don
Thanks for the code. I've got it working, but I've just been told that the
data that is exported needs to be delimited by field size any idea on how to
do this.
Thanks
Mohamed
> > Any idea on how one can export certain columns in a mySQL database to
> > delimited text files using PHP.
> >
>
> $qry=" SELECT col1,col2,col ... FROM table";
> if ($res= mysql_query($qry)) {
> $fp=fopen('data.csv', 'w');
> while ($row = mysql_fetch_row($res)) {
> fputs($fp, "'" .implode("','", $row)
> ."'\n");
> }
> fclose($fp);
> }
>
> Regards,
> --
> Don Read dread@texas.net
> -- It's always darkest before the dawn. So if you are going to
> steal the neighbor's newspaper, that's the time to do it.