|  | 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] |