PDA

View Full Version : ¿php question?



TheRunes
July 3rd, 2001, 02:16
Is it possible to have a website made in php that loads each page from a txt file?
What i mean is:
the main page loads (index.php)
then the user clicks a link... and index.php gets reloaded with the content from a txt file.

I believe it can be done...
I dont know how...
I have basic understanding of php...
the majority of my knowledge is include and require functions...
if my idea is possible... can someone help me make it reality?

ashben
July 3rd, 2001, 02:36
Sure, just include the content's of a text file in the index script:


include("textfile.txt")

You may also use SSI or File Scripting.

keith
July 3rd, 2001, 19:06
<?
if (!$QUERY_STRING) {
include("pages/home.txt");
} else {
include("pages/$QUERY_STRING.txt");
}
?>

in this example, all your .txt files are in a directory called /pages/



if you just type in your domain, and inex.php is called, it will load by default /pages/home.txt



if you link to /index.php?freeware it will load /pages/freeware.txt



this way, you don't have to specify every .txt file in your directory. whenever one's added or deleted, just link to it, no setting it up in the script itself.



it might be wise as well to use .php files as opposed to .txt files. same thing, just a different extension. might work faster with a .php index file, i'm not sure, but that preobably wouldn't be noticeably faster anyhow.



and use the index file to store your header and footer, so changes to your site's layout can be changed sitewide by editing just the index file:

<html>
<head>
<title>My Homepage</title>
</head>
<body>

<?
if (!$QUERY_STRING) {
include("pages/home.php");
} else {
include("pages/$QUERY_STRING.php");
}
?>

</body>
</html>
and store the .php files in a directory called /pages/, or whatever you want...


hope that helps. it works exactly the way you want it to... i use this setup with http://www.joebluhm.com [click "contact", it's the only section finished right now]

bigperm
July 4th, 2001, 00:33
Thank you keith... that is exactly what I was looking for too... I think I am going with the whole dreamweaver template thing though now.

keith
July 4th, 2001, 01:11
dreamweaver?? hehehehe...

bigperm
July 4th, 2001, 01:25
I didn't spend an hour downloading it, just to have it sit there.

Koolguy
July 5th, 2001, 21:49
you gotta love warez :p