Hey all,
I had my other question answered and i am well on my way to completeing this except for this one problem.
PROBLEM:
I want this code to loop through the database and write the names of people in a text file- which is is doing marvelously. BUT it is writing them all on one line 🙁 I have tried to insert the /r/n to try to make it add a New Line character, but that just prints the /r/n in the text file 🙁 I have also tried (of course) the good old /n as well with the same result.
Does anyone know how to make PHP write the name on one line, and then write the next name on the next line?
Here is my code so far:
<?PHP
INCLUDE("datavars.php");
#########################
## Connect to Database ##
#########################
$Link1 = mysql_connect($Host, $User, $Password);
mysql_select_db($DBName, $Link1);
$Query1 = "SELECT user from $TableName1 where status = '1'";
$Result1 = mysql_query($Query1, $Link1);
######################################
## This is a test of File Functions ##
######################################
Print ("
<html>
<head>
<title>File Functions Test</title>
</head>
<body>
These folks should now be in the file (hopefully):
<br>
");
While ($Array2 = mysql_fetch_array($Result1)) {
$filename = "test.txt";
$fileopen = fopen($filename,"a+") or die("File not Found, or other error occured!<br>");
$filewrite = fwrite($fileopen, "$Array2[user]/r/n") or die("Could not Write to file!!<br>");
fclose($fileopen);
Print ("$Array2[user]...Added<br>");
}
print ("
</body>
</html>
");
?>
Any help would be greatly appreciated 🙂