Page 1 of 1

How to write from file to HTML

Posted: Tue Aug 31, 2004 5:36 am
by Sorcerer
Hi everybody!!!!

I have a problem and hope you could help me out....
I'm new to PHP, but need to use it for one function....
This function should recive a filename and the open the
file( which is located on server side) and write it line by
line in to a cell of a HTML table.... I've been trying to do this
and I was told it is easy to do... but didn't manage.... :(
Can anyone help me PLEASE!!! Or give me a link to some
tutorial that would explain how to make this things??
Any help appreciated!!

Posted: Tue Aug 31, 2004 7:54 am
by McGruff
See manual: [php_man]include[/php_man]

Posted: Tue Aug 31, 2004 8:43 am
by ol4pr0
Or if u mean a text file.. *.txt that is.

Code: Select all

$file = "youre_text_file.txt";
		$fh = fopen($file,'r') or die ("couldnt open file to read");
		$file_size =filesize($file);
		$fcontent = fread($fh,$file_size);
		fclose ($fh);
		echo '<pre>';
		echo $fcontent;
		echo '</pre>';

Posted: Tue Aug 31, 2004 9:11 am
by timvw
in that case [php_man]readfile[/php_man] is even less lines ;)

Posted: Tue Aug 31, 2004 12:03 pm
by Sorcerer
Thanks a lot :D
U made me happy :D