Re: exporting data

From: Date: Sun, 20 Apr 2003 08:48:34 +0000
Subject: Re: exporting data
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-144527@lists.php.net to get a copy of this message
On 20-Apr-2003 M.E. Suliman wrote: > 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. > sprintf(); > 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. -- 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.

« previous php.general (#144527) next »