Since I last posted to this forum (a long time ago now), I've managed to get my website up and running. http://www.didymus.org.uk/ is where you'll find it.
I need a little help with some simple code. Basically, I need to know if there's a way of condensing this code down a little. In particular the
lines as there are 31 of them!if ( $date == "**" )
You can see the code in action at http://www.didymus.org.uk/date.php
Anway, here's my code:
Code: Select all
<?php
/* Program: date.php
* Desc: Displays date and time and custom poem.
*/
// SET VARIABLES FOR DISPLAY
$day = date ("l");
$date = date ("j");
$month = date ("F");
$year = date ("Y");
$hour = date ("H");
$mins = date ("i");
$secs = date ("s");
if ( $date == "1" )
{ $suffix = "st" ;}
if ( $date == "2" )
{ $suffix = "nd" ;}
if ( $date == "3" )
{ $suffix = "rd" ;}
if ( $date == "4" )
{ $suffix = "th" ;}
if ( $date == "5" )
{ $suffix = "th" ;}
if ( $date == "6" )
{ $suffix = "th" ;}
if ( $date == "7" )
{ $suffix = "th" ;}
if ( $date == "8" )
{ $suffix = "th" ;}
if ( $date == "9" )
{ $suffix = "th" ;}
if ( $date == "10" )
{ $suffix = "th" ;}
if ( $date == "11" )
{ $suffix = "th" ;}
if ( $date == "12" )
{ $suffix = "th" ;}
if ( $date == "13" )
{ $suffix = "th" ;}
if ( $date == "14" )
{ $suffix = "th" ;}
if ( $date == "15" )
{ $suffix = "th" ;}
if ( $date == "16" )
{ $suffix = "th" ;}
if ( $date == "17" )
{ $suffix = "th" ;}
if ( $date == "18" )
{ $suffix = "th" ;}
if ( $date == "19" )
{ $suffix = "th" ;}
if ( $date == "20" )
{ $suffix = "th" ;}
if ( $date == "21" )
{ $suffix = "st" ;}
if ( $date == "22" )
{ $suffix = "nd" ;}
if ( $date == "23" )
{ $suffix = "rd" ;}
if ( $date == "24" )
{ $suffix = "th" ;}
if ( $date == "25" )
{ $suffix = "th" ;}
if ( $date == "26" )
{ $suffix = "th" ;}
if ( $date == "27" )
{ $suffix = "th" ;}
if ( $date == "28" )
{ $suffix = "th" ;}
if ( $date == "29" )
{ $suffix = "th" ;}
if ( $date == "30" )
{ $suffix = "th" ;}
if ( $date == "31" )
{ $suffix = "st" ;}
echo "<p align='center'><font size='2' face='Arial'>$day $date$suffix $month $year | $hour:$mins:$secs<br><br>Monday's Child Poem";
if ( $day == "Monday" )
{ echo "<p align='center'><font size='2' face='Arial'><font color='#FF0000'>Monday's child is fair of
face,</font><br>
Tuesday's child is full of grace,<br>
Wednesday's child is full of woe,<br>
Thursday's child has far to go,<br>
Friday's child is loving and giving,<br>
Saturday's child works hard for his living,<br>
And the child that is born on the Sabbath day<br>
Is bonny and blithe, and good and gay.</font></p>";}
if ( $day == "Tuesday" )
{ echo "<p><font size='2' face='Arial'>Monday's child is fair of face,<br>
<font color='#FF0000'>Tuesday's child is full of grace,</font><br>
Wednesday's child is full of woe,<br>
Thursday's child has far to go,<br>
Friday's child is loving and giving,<br>
Saturday's child works hard for his living,<br>
And the child that is born on the Sabbath day<br>
Is bonny and blithe, and good and gay.</font></p>";}
if ( $day == "Wednesday" )
{ echo "<p><font size='2' face='Arial'>Monday's child is fair of face,<br>
Tuesday's child is full of grace,<br>
<font color='#FF0000'>Wednesday's child is full of woe,</font><br>
Thursday's child has far to go,<br>
Friday's child is loving and giving,<br>
Saturday's child works hard for his living,<br>
And the child that is born on the Sabbath day<br>
Is bonny and blithe, and good and gay.</font></p>";}
if ( $day == "Thursday" )
{ echo "<p><font size='2' face='Arial'>Monday's child is fair of face,<br>
Tuesday's child is full of grace,<br>
Wednesday's child is full of woe,<br>
<font color='#FF0000'>Thursday's child has far to go,</font><br>
Friday's child is loving and giving,<br>
Saturday's child works hard for his living,<br>
And the child that is born on the Sabbath day<br>
Is bonny and blithe, and good and gay.</font></p>";}
if ( $day == "Friday" )
{ echo "<p><font size='2' face='Arial'>Monday's child is fair of face,<br>
Tuesday's child is full of grace,<br>
Wednesday's child is full of woe,<br>
Thursday's child has far to go,<br>
<font color='#FF0000'>Friday's child is loving and giving,</font><br>
Saturday's child works hard for his living,<br>
And the child that is born on the Sabbath day<br>
Is bonny and blithe, and good and gay.</font></p>";}
if ( $day == "Saturday" )
{ echo "<p><font size='2' face='Arial'>Monday's child is fair of face,<br>
Tuesday's child is full of grace,<br>
Wednesday's child is full of woe,<br>
Thursday's child has far to go,<br>
Friday's child is loving and giving,<br>
<font color='#FF0000'>Saturday's child works hard for his living,</font><br>
And the child that is born on the Sabbath day<br>
Is bonny and blithe, and good and gay.</font></p>";}
if ( $day == "Sunday" )
{ echo "<p><font size='2' face='Arial'>Monday's child is fair of face,<br>
Tuesday's child is full of grace,<br>
Wednesday's child is full of woe,<br>
Thursday's child has far to go,<br>
Friday's child is loving and giving,<br>
Saturday's child works hard for his living,<br>
<font color='#FF0000'>And the child that is born on the Sabbath day<br>
Is bonny and blithe, and good and gay.</font></font></p>";}
?>KD.