Page 1 of 1

automating updates by date.

Posted: Tue Mar 04, 2003 10:51 am
by basil
I am new to php programming. Can anyone advise how to have my monthly newsletter and quiz update automatically on my website as the date changes each month. Is that simply an "if" "else" situation by having the date validate T/F or is there a function for this. Can't seem to find info or tutorials.
Thanks
Basil

Posted: Tue Mar 04, 2003 1:29 pm
by redJag
If the files containing your newsletter and quiz can easily be named by date it would be pretty simple. Just get the current date and display the files that have that date in their name.

Posted: Tue Mar 04, 2003 2:10 pm
by basil
Have to think about that. I need 1 newsletter/quiz per month so not sure file name would work. Was thinking of making a variable from a date range IE >=mar1/03 and <=Mar31/03...then checking the current date and if true echo the file. Just not sure if that will work, and if so...not sure how to do it...
Thanks for your reply
Glenn

Posted: Tue Mar 04, 2003 10:09 pm
by McGruff
In rough outline, and assuming you've got all the content stored in a database, add a publication date column for each content row.

One way to do this would be to make a tinyint(2) column where you store 01, 02, 03 etc depending on the month you want to publish the item.

In the script which draws the page, get the current month with:

$current_month = date("m", time()); // eg gives 03 for March

..and then

SELECT whatever, cols, you, need FROM the_content_table WHERE publication_date='$current_month'

Posted: Tue Mar 04, 2003 10:29 pm
by basil
Thanks for your reply. Will try to get my head around your suggestion. Can see it working for quiz but not sure if newsletter content and graphics etc. can be stored in a database...perhaps???

Will keep digging and learning.
Thanks again
Basil

Posted: Wed Mar 05, 2003 12:41 am
by McGruff
I wouldn't put graphics in a database - although some people do. If some graphics change once a month, you could stick img src links to them in the database with a publication date as above.

Newsletter text can go in a database no problem - lots of sites do it.

I don't know how familiar you are with php - take a look at some web tutorials if you haven't worked with databases much.

Ypou could even try something ready-rolled like the postnuke CMS.

Posted: Wed Mar 05, 2003 3:50 pm
by redJag
If you save your monthly newsletter and quiz into files labeled newsletter##-####.html where ##-#### = numerical month-4 digit year then you can just use find out what month-year it is when the page is loaded and use an include respective to the date.

Code: Select all

<?php
$month = date("m", time());
$year  = date("Y", time());

//HTML and PHP to appear before and around newsletter here

include("newsletter".$month."-".$year.".html"); //or whatever extension

//HTML and PHP between newsletter and quiz here

include("quiz".$month."-".$year.".php");

//HTML and PHP after newsletter and quiz here

?>

Posted: Wed Mar 05, 2003 7:04 pm
by basil
Thanks so much!...I'll try and make that work

Glenn

Posted: Wed Mar 05, 2003 10:36 pm
by McGruff
Ah.. yes.. month/year would be better if you maintain old items in the database - otherwise you'd be printing last years' March/ etc articles as well as the current ones.