Hi everyone,
I've recently started with PHP and i'm running into some problems. I've tried doing a search on this forum but couldn't find what I needed.
From the index.php I want to include any .news files so all I need to do to update my news is add a new .news file.
This works but only reads one single file...
<?php
include('news/20032002.news');
?>
I know I can add it again pointing to the new .news file but this is what i'm trying to avoid obviously.
So far all I can do is display the contents of the news directory like this:
<?php
if ($handle = opendir('news')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
echo "$file\n";
}
}
closedir($handle);
}
?>
Here is my directory structure: (p.s. I'm using XP pro IIS)
wwwroot/
default.htm
wwwroot/MyPage/
index.php
wwwroot/MyPage/news/
20032002.news
21032002.news
(Within the .news files is a html table and the actual news)
I hope someone can help me with this...
=============================================
I did:
<?php
if ($handle = opendir('news')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
chdir("news");
include("$file");
chdir("../");
}
}
closedir($handle);
}
?>
And it seems to work almost exactly like I want it to. I need it check for date and time now in order to get the latest .news file on top in my page. Here is where I have no cleus at all how to do that so If anyone could help me with that It would be greatly appreciated