Irish SEO,  Marketing & Webmaster Discussion

 
Chitika Malls

PHP Include (Most Recent HTML File)?

This is a discussion on PHP Include (Most Recent HTML File)? within the Coding Help forums, part of the Webmaster Help category; I'm trying to use the php include function to call a html file into a php page. The html files ...


Go Back   Irish SEO, Marketing & Webmaster Discussion > Webmaster Help > Coding Help

Register Forum Rules FAQDonate Members List Calendar Search Today's Posts Mark Forums Read


Notices

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 28-03-2007, 02:28 PM
ButtermilkJack's Avatar
Wannabe Geek
 
Join Date: Feb 2006
Location: Dublin, Ireland
Posts: 267
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
ButtermilkJack will become famous soon enough
Default PHP Include (Most Recent HTML File)?

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?
__________________
Print & Web Design
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 28-03-2007, 02:54 PM
Wannabe Geek
 
Join Date: Sep 2006
Posts: 193
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
dude will become famous soon enough
Default

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...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 28-03-2007, 03:34 PM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 2,048
Nominated 5 Times in 3 Posts
Nominated TOTW/F/M Award(s): 1
louie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enough
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

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
:. Directory Submission Directory Submission
:. News & Press Release Ireland GiveItSocks.com
:. Used Cars Ireland, Car Parts & Car Audio Cars For Sale, Car Parts & Accessories
:. I Have 2 Find It Directory SEF Directory
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 28-03-2007, 04:05 PM
ButtermilkJack's Avatar
Wannabe Geek
 
Join Date: Feb 2006
Location: Dublin, Ireland
Posts: 267
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
ButtermilkJack will become famous soon enough
Default

Quote:
Originally Posted by dude View Post
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...
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!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 28-03-2007, 07:33 PM
niall's Avatar
Hosting Caretaker
 
Join Date: Jan 2007
Location: Carlow
Posts: 65
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
niall will become famous soon enough
Send a message via ICQ to niall Send a message via MSN to niall
Default

Quote:
Originally Posted by ButtermilkJack View Post
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.
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:
PHP 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"
This is a totally untested quick and dirty example 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.
__________________
Blog
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 28-03-2007, 09:25 PM
niall's Avatar
Hosting Caretaker
 
Join Date: Jan 2007
Location: Carlow
Posts: 65
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
niall will become famous soon enough
Send a message via ICQ to niall Send a message via MSN to niall
Default

Actually, replace all instances of filectime with filemtime, that will give you the last modified time which is what you need.

Niall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7 (permalink)  
Old 29-03-2007, 09:19 AM
ButtermilkJack's Avatar
Wannabe Geek
 
Join Date: Feb 2006
Location: Dublin, Ireland
Posts: 267
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
ButtermilkJack will become famous soon enough
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
file, html, include, php, recent

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


Sponsored links

Paid On Results


All times are GMT +1. The time now is 04:35 AM.


Powered by: vBulletin Version 3.7.3, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
Hosted in Ireland by Blacknight - Test your ISP |Irish Hosting Directory| Armchair.ie|Logo by Eden Web Design|Avatars by Afterglow |Latest Blog Entries | VPS HostingAd Management by RedTyger

Search Engine Friendly URLs by vBSEO 3.2.0