Hi guys,
So today I am trying to do something that is probably quite simple. But my head is all over the place and I can barely think straight! Something which is not good for a newb!
I'm trying to display some text files on the web. These text files are all in their own seperate directory. I want to be able to list the directory. When you the file you want to view you are brought to a page which uses this code to display the text:
<?php
$myFile = "directory/file.txt";
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);
echo "<pre>$theData</pre>";
?>
The code I have to display the directory is:
<?php
$dir = "poems/";
if($scan = scandir($dir)){
foreach ($scan as $value){
if($value != "." && $value != ".."){
echo $value."<br />";
}
}
}
?>
So in summary what I want is:
1. Using the second piece of code or similar display a list of contents.
2. Once you choose a link the page it displays using the first piece of code or similar.
I presume I should be using some kind of template solution to make my site run the way i want.
I'm sorry if I explained it all over the place but as I said im kind of all over the place at the moment! Thanks guys