automating updates by date.
Moderator: General Moderators
automating updates by date.
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
Thanks
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
Thanks for your reply
Glenn
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'
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'
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.
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.
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
?>