hi, i decided not too long ago to completly destroy my site and start from scratch. on the index page i want a news bar that will be updated automaticaly with the .txt files i put in the news/ directory.
the one i am using atm is this:
[php]<?php
if ($handle = opendir(‘news/’)) {
$i = 1;
while ($file = readdir($handle)) {
if($file != "." && $file != ".." && $file)
$i++;
}
$n = 1;
while($n < $i) {
$contents = file_get_contents("news/$n.txt");
$contents2 = explode("|-|",$contents);
echo "<div class=newstitle><a href='index.php?p=$n'>" . $contents2[0] . "</a></div><br/>";
echo "<div class=newscont>" . $contents2[1] . "</div><br /><hr/>";
$n++;
}
closedir($handle);
}
?> [/php]
and it works fine but i have to name the files 1.txt 2.txt 3.txt etc and would rather name them anything i wanted. so i started a new one and would work but when i open the link to index.php?p=$file it cannot read the txt file as it is trying to read (filename).txt.txt. please help