Reputation: 2647
So im trying to write to a flatfile. A word from a database is written every time it meets a certain criteria. The problem is after the script runs, only the last word that met the criteria shows up in the file. Obviously the words are being written, then over written by the next word. How can i fix this? I want each word to be written to its own line. Heres my code.
<?php
include 'special.class.php';
require 'db_config.php';
$result = mysql_query("SELECT * FROM words limit 0, 30") or die ("Could not make query");
while($row = mysql_fetch_array($result))
{
$word = $row['result'];
$special_word = new word_stuffs( $word);
if ($special_word>is_special()) {
$File = "words.txt";
$Handle = fopen($File, 'w');
$Data = $word;
fwrite($Handle, $Data);
fclose($Handle);
} else {
echo "Not special!!";
}
}
?>
Upvotes: 0
Views: 58
Reputation: 6393
$Handle = fopen($File, 'a');
instead of
$Handle = fopen($File, 'w');
Upvotes: 1