You are here: Re: writing records to text file « PHP SQL « IT news, forums, messages
Re: writing records to text file

Posted by NC on 10/26/05 21:47

Ian Davies wrote:
>
> I have the following code which displays some some formatted
> text in my browser. The problem is I need to create a text file
> and write the records from this array into it.

Shouldn't be too difficult...

$query = "select * from Questions";
$rt = mysql_query($query)
or die(mysql_error());
$fp = fopen('mydata.txt', 'w')
or die('Could not open the text file for writing');
while ($nt = mysql_fetch_array($rt, MYSQL_NUM)){
$line = "INSERT INTO tQuestions VALUES (" .
implode(',', $nt) .
");\r\n";
fwrite($fp, $line);
}
fclose($fp);

Cheers,
NC

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация