|
Posted by Chris Hope on 05/26/05 00:07
KiwiBrian wrote:
> I would like to create once a week, 7 pages, one for each day of the
> following week, with just the page of the day accessible from a common
> link. For example "Click here for the program of the day".
> Can this functionality be implemented so that the link gets changed
> automatically for each day, thus meaning that I can set it up for the
> week and forget it until next week?
Yes.
> I am not a programmer, but am reasonably familiar with HTML and CSS.
> I have been advised that this would be relatively trivial to implement
> in PHP, which my server supports.
> If so, where would I look on the web for such a script and how to
> implement it?
The date() function can be used to determine what the current day is and
then it would be a simple matter of doing an if-then or switch
statement to create the link.
An easier way of doing it would be to just name the page names after the
day of the week and then your link would look something like this:
<a href="<?php echo date('l') ?>.php">blah blah blah</a>
If today is Monday the link above would look like this in the outputted
html:
<a href="Monday.php">blah blah blah</a>
If you wanted to make it all lower case (ie "monday" instead of
"Monday") then do this:
<a href="<?php echo strtolower(date('l')) ?>.php">blah blah blah</a>
To implement an if-then statement instead you'd be looking at something
like this:
<?php
function get_link() {
$day = date('l');
if($day == 'Monday') {
$link = 'foo.php';
}
elseif($day == 'Tuesday') {
$link = 'bar.php';
}
...
}
?>
<a href="<?php echo get_link() ?>">blah blah blah</a>
--
Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
[Back to original message]
|