Include a txt file in php file

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
xterra
Forum Commoner
Posts: 69
Joined: Mon Mar 06, 2006 12:52 pm

Include a txt file in php file

Post 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.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Include a txt file in php file

Post 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.
(#10850)
xterra
Forum Commoner
Posts: 69
Joined: Mon Mar 06, 2006 12:52 pm

Re: Include a txt file in php file

Post 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.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Include a txt file in php file

Post by Jonah Bron »

Post Reply