Re: Writing & Displaying Records

From: Date: Thu, 05 Oct 2000 05:27:13 +0000
Subject: Re: Writing & Displaying Records
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-18701@lists.php.net to get a copy of this message
On Thu, 05 Oct 2000, Andrew V. Romero wrote: > I have been trying to make a php file that will write the contents of an > html form to a file and this just display that data. Let me give an > example, I have a html form with just one text entry called data. The > user is going to enter a word into this form and then once they hit > submit I want the php file to write what they entered and display what > other people have entered. To do this I tried: > $wd=fopen("writedata.txt","a"); > $wdata=fwrite($wd,$data); > fclose($wd); > $wd=fopen("writedata.txt","r"); > $currentdata=fgets($wd,50); > echo "<br>Data Currently in File: $currentdata"; > but that jams all the data entered by the various users together and I > can't figure out how to seperate it out when I am trying to display it. > I don't know if I am writing the file wrong and it is getting crammed > together or if it is the way that I am reading the file. If you know of > any tutorials that can help me, or if you would be willing to give me a > hand I would really appreciate it. > Thanks Presumably the records in your text file are separated by carriage returns? Remember that browsers treat carriage returns, spaces and tabs as 'white space' and essentially discard them. You need to use nl2br to convert your newlines (carriage returns) to BR tags. -- David Robley | WEBMASTER & Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet | http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA

« previous php.general (#18701) next »