Use the 'system' command with 'stat filename' and then rip out the bit you're interested in?
Why do you want to put your html files in a database? Seems a bit overly complex...
I'm trying to use the php include function to call a html file into a php page. The html files are just residing in my root folder as there's no need to keep them in a database just yet. However, I want to be able to call the most recent html file each time. Do I need to use a database for this? Is there any other way to date-stamp the html files?
Use the 'system' command with 'stat filename' and then rip out the bit you're interested in?
Why do you want to put your html files in a database? Seems a bit overly complex...
yes use a database and just store the path to the file including the date last modified, so you can access the last one all the time.
:. Web Design & Development Web Design Ireland
:. Search Engines Optimization Search Engines Optimization
:. Car Parts & Accessories Car Parts
:. Cars Ireland Cars Ireland
:. I Have 2 Find It Directory SEF Directory
Hi, thanks for the reply. I don't want to put my html files in a database. That's the thing. I'm trying to find a way of doing it so that I can just keep them in the root folder.
I'm just beginning with PHP so am not to up on system and stat filename but I'll look into it. Cheers!
A database would be total over kill for this. Use opendir to open the directory containing the html files and readdir to loop through the files in the directory. For each html file, use filectime to see when the file was last changed.
The basic code to get the file you want is:
This is a totally untested quick and dirty examplePHP Code:$dirname="/path/to/html/";
$filename="";
$filetime=0;
$dir=opendir($dirname);
while($file=readdir($dir))
{
if($file != '.' && $file != '..')
{
if(filectime($file) > $filetime)
{
$filename=$file;
$filetime=filectime($file);
}
}
}
print "$dirname$file\n";
There is plenty of error checking that can be added (did the directory open, is the file html etc.) but it should get you pointed in the right direction without the pain of adding a database to the mix.
Actually, replace all instances of filectime with filemtime, that will give you the last modified time which is what you need.
Niall
Excellent niall, that sounds perfect. Thanks a million. I'll try it out now!
Just to fill you in, I run a local football club website and have to update the fixtures/results page each week. It's not archived at the moment so all I want to do is create the html file, dump it into a folder in the root and let the webpage call it up.
This script should do the job nicely![]()