I'd like to write the content of the variable $rows into the file out.txt.
The variable $rows is placed within a while loop and can be constituted by several different rows retrieved from a database.
Unfortunately, the following code just writes one single line (the last one precisely) of the expected output.
$myFile = "/var/www/test/out.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$content = $rows['text'];
fwrite($fh, $content);
fclose($fh);
Here is the PHP code (which is working) that allows me to see the contents of the $rows variable in the browser.
<?
if(isset($_POST['type'], $_POST['topic'], $_POST['tense'], $_POST['polarity']))
{
$tipo = $_POST['type'];
$argomento = $_POST['topic'];
$tempo = $_POST['tense'];
$segno = $_POST['polarity'];
foreach ($tipo as $key_tipo => $value_tipo)
{
foreach ($argomento as $key_argomento => $value_argomento)
{
foreach ($tempo as $key_tempo => $value_tempo)
{
foreach ($segno as $key_segno => $value_segno)
{
$q_tip_arg_tem_seg = "SELECT * FROM entries WHERE type = '".$value_tipo."' AND topic = '".$value_argomento."' AND tense = '".$value_tempo."' AND polarity = '".$value_segno."'";
$qu_tip_arg_tem_seg = mysql_query($q_tip_arg_tem_seg);
while ($rows = mysql_fetch_array($qu_tip_arg_tem_seg))
{
echo $rows['type']."<br />";
}
}
}
}
}
}
else
{
echo "You forgot to check something."."<br>"."Please select at least one type, topic, tense and polarity value."."<br>";
}
?>
Can you help me out? Thanks.