Page 1 of 1

Include a txt file in php file

Posted: Fri Feb 15, 2008 6:31 pm
by xterra
Hey guys and gals,
Article.php?ID=5 accesses the mySQL DB, determines the filename of the text file that ID 5 corresponds to(i.e. Election2008.txt), and then will output it. I don't want to it to go directly to the .txt file because then it won't be formatted. Here is my PHP:

Code: Select all

 
<?
...query code not important...
$file_to_output  = mysql_result($result,0,"location");
 
echo
 "<html> <!--formatting codes--!>
[b]Right here is where I want the text to be placed from the textfile $file_to_output[/b]
</html>
";
close();
?>
 
Thanks.

Re: Include a txt file in php file

Posted: Fri Feb 15, 2008 8:04 pm
by Christopher
Check the PHP manual for a MySQL example. You need to fetch the row after your query, then include the file using a value in the row.

Re: Include a txt file in php file

Posted: Fri Feb 15, 2008 8:16 pm
by xterra
arborint wrote:Check the PHP manual for a MySQL example. You need to fetch the row after your query, then include the file using a value in the row.
Thanks, but as you can see from the above code I already know that. I do not understand the how to output it, i.e. grab the text from the textfile and printing it. There's physically a textfile on the server, I need to know how to get the contents of which.

Re: Include a txt file in php file

Posted: Tue Feb 19, 2008 5:11 pm
by Jonah Bron