NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Need a special PHP 'include'

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 08-27-2008, 05:50 AM THREAD STARTER               #1 (permalink)
DomainersUniversity.com
 
Gene's Avatar
Join Date: Feb 2005
Location: Oswego, NY
Posts: 4,735
Gene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond repute
 


Member of the Month
April 2005
Ethan Allen Fund Cancer Survivorship Baby Health Cystic Fibrosis Marrow Donor Program Parkinson's Disease Child Abuse Save a Life Animal Rescue Save a Life Save a Life Animal Rescue

Need a special PHP 'include'


Let's say I have hundreds of HTML files, each named for a particular day of the year.

I need to use the PHP 'include' code so on any particular system date, the matching HTML file is included. So, since today is August 27, 2008, the 'include' file should be 2008-08-27.html

Understand that the html files have not been created yet, so the naming of these files can be in a different date format if need be.

------------------------

Then I need to have another 'include' code that will take the system date and subtract a number of days, so it will 'include' a HTML file that is X number of days in the past.

For example, today is August 27, 2008, and I want the web page to 'include' a file named for a date 3 days ago, which would be 2008-08-24.html.

------------------------

Seems like a fairly simple thing to do, but I don't know coding well enough to figure it out. Any help would be great!




.
__________________
.
.

Expired Domain Search -- ExpiredDomainBoss.com | Sell Domain Names -- DomainProfitsClub.com
-----------------------------------------------------------------------------------------------
Gene is offline  
Old 08-27-2008, 06:15 AM   #2 (permalink)
Hi :)
 
Mark's Avatar
Join Date: Mar 2004
Location: NC
Posts: 9,566
Mark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatness
 

Member of the Month
August 2004
Ethan Allen Fund
Well the part of it to include "Today" could be :

Code:
<?php

$today = date("Ymd");

include("includes/$today.php");

?>
That would actually show the date as "20080827" - And as a whole number you could simply Subtract numbers from that to show archives of days past.
????: NamePros.com http://www.namepros.com/programming/508057-need-a-special-php-include.html

Code:
$yesterday = $today-1;

That may be a bit too simple for what you are looking for Gene - But it's 8 AM here and I'm out of Mountain Dew

SOS DEW ME !

Obviously - That is limited to one month though ...
Mark is offline  
Old 08-27-2008, 06:44 AM THREAD STARTER               #3 (permalink)
DomainersUniversity.com
 
Gene's Avatar
Join Date: Feb 2005
Location: Oswego, NY
Posts: 4,735
Gene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond repute
 


Member of the Month
April 2005
Ethan Allen Fund Cancer Survivorship Baby Health Cystic Fibrosis Marrow Donor Program Parkinson's Disease Child Abuse Save a Life Animal Rescue Save a Life Save a Life Animal Rescue
Thanks Mark!
That seems like it would work (based on my limited understanding of PHP), but I'm wondering why you say it would be limited to 1 month. Couldn't it say $yesterday = $today-47; for instance?


So do I have this right?

PHP Code:
<?php

$today 
date("Ymd");
$yesterday $today-1;
include(
"includes/$today.php");

?>

(which would use file: 20080827.php)
????: NamePros.com http://www.namepros.com/showthread.php?t=508057



OR



<?php

$today 
date("Ymd");
$yesterday $today-3;
include(
"includes/$yesterday.php");

?>

(which would use file: 20080824.php)

----------------------------
EDIT: Mark, you're da man! I just tried the code and it works perfectly. THANK YOU!





.
__________________
.
.

Expired Domain Search -- ExpiredDomainBoss.com | Sell Domain Names -- DomainProfitsClub.com
-----------------------------------------------------------------------------------------------
Last edited by Gene; 08-27-2008 at 07:24 AM.
Gene is offline  
Old 08-27-2008, 07:46 AM   #4 (permalink)
Hi :)
 
Mark's Avatar
Join Date: Mar 2004
Location: NC
Posts: 9,566
Mark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatness
 

Member of the Month
August 2004
Ethan Allen Fund
No - it wont work for other months due to the fact it is combining Y M D into one number. "20080827" is just "20 Million 80 thousand and 27" to the script. If you subtract more than 26 , There would be an error if you tried to incude any pages.

For individual dates , You really need a more detailed Calendar set up and something in the script to ask "if file exists" to make sure it doesn't try to include dates non-existent. http://www.php.net/date has all of the available formats. I'm thinking in your case maybe using the "Day of Year" format may help.
Quote:
z The day of the year (starting from 0) 0 through 365
Here is a piece of a script I use to pull up "Todays Database" :

Code:
$today = date("Ymd");
if(!isset($filename) || !$filename || $filename == ""){$filename = "database/$today.txt";}
	if(!file_exists("$filename")) {

///it does exist - so retrieve and show data (include it in your case)

} else {

///it doesn't exist - So no Go (I actually create the database here on my script)

}
I'll do some more thinking and digging on it after a Trip to the store (Mountain Dew Trip)

I'd bet some of these younger "whippersnappers" might have a better way to do this than me
Mark is offline  
Old 08-27-2008, 07:58 AM THREAD STARTER               #5 (permalink)
DomainersUniversity.com
 
Gene's Avatar
Join Date: Feb 2005
Location: Oswego, NY
Posts: 4,735
Gene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond repute
 


Member of the Month
April 2005
Ethan Allen Fund Cancer Survivorship Baby Health Cystic Fibrosis Marrow Donor Program Parkinson's Disease Child Abuse Save a Life Animal Rescue Save a Life Save a Life Animal Rescue
You're right... I just tried doing a -30 and it failed... it won't overlap into the previous month. Thanks for the additional info though!
__________________
.
.

Expired Domain Search -- ExpiredDomainBoss.com | Sell Domain Names -- DomainProfitsClub.com
-----------------------------------------------------------------------------------------------
Gene is offline  
Old 08-27-2008, 07:58 AM   #6 (permalink)
Traveller
 
-NC-'s Avatar
Join Date: Mar 2007
Location: Yet another city
Posts: 1,419
-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future
 


Animal Cruelty Animal Rescue Ethan Allen Fund Protect Our Planet
The strtotime function is almost unbelievably clever at working out date stuff, you can even tell it what to do in almost plain english:

Code:
$yesterday = date('Ymd', strtotime("-1 day"));
$lastmonth = date('Ymd', strtotime("-1 month"));
check out some of the more extreme examples:
????: NamePros.com http://www.namepros.com/showthread.php?t=508057
Code:
strtotime("last Monday")
strtotime("next Thursday")
http://php.net/strtotime
__________________
NameCooler.com
-NC- is offline  
Old 08-27-2008, 08:07 AM THREAD STARTER               #7 (permalink)
DomainersUniversity.com
 
Gene's Avatar
Join Date: Feb 2005
Location: Oswego, NY
Posts: 4,735
Gene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond repute
 


Member of the Month
April 2005
Ethan Allen Fund Cancer Survivorship Baby Health Cystic Fibrosis Marrow Donor Program Parkinson's Disease Child Abuse Save a Life Animal Rescue Save a Life Save a Life Animal Rescue
-NC-! Beautiful! That works like a charm... man you've saved me a lot of hair-pulling. Thanks so much.
__________________
.
.

Expired Domain Search -- ExpiredDomainBoss.com | Sell Domain Names -- DomainProfitsClub.com
-----------------------------------------------------------------------------------------------
Gene is offline  
Old 08-27-2008, 10:53 AM   #8 (permalink)
Hi :)
 
Mark's Avatar
Join Date: Mar 2004
Location: NC
Posts: 9,566
Mark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatnessMark Has achieved greatness
 

Member of the Month
August 2004
Ethan Allen Fund
I told you one of those Younger folks would know a better way

Thanks -NC-
Mark is offline  
Old 08-27-2008, 10:59 AM THREAD STARTER               #9 (permalink)
DomainersUniversity.com
 
Gene's Avatar
Join Date: Feb 2005
Location: Oswego, NY
Posts: 4,735
Gene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond reputeGene has a reputation beyond repute
 


Member of the Month
April 2005
Ethan Allen Fund Cancer Survivorship Baby Health Cystic Fibrosis Marrow Donor Program Parkinson's Disease Child Abuse Save a Life Animal Rescue Save a Life Save a Life Animal Rescue
Thanks to both of you for taking the time! And Mark, you're still the best eye-poker
__________________
.
.

Expired Domain Search -- ExpiredDomainBoss.com | Sell Domain Names -- DomainProfitsClub.com
-----------------------------------------------------------------------------------------------
Gene is offline  
Old 08-28-2008, 06:36 PM   #10 (permalink)
Senior Member
Join Date: Apr 2005
Location: Joliet, Illinois
Posts: 1,177
RageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to beholdRageD is a splendid one to behold
 


Child Abuse
Good call, glad I read this thing through instead of just posting like normal then I would've made a double post xD good job -NC-

-RageD
RageD is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 11:44 PM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger