Created
June 20, 2013 13:36
-
-
Save charleyramm/5822740 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* /masterpieces/events/index.php | |
* Simple PHP events block | |
* Display events block, ignoring those events that have already happened | |
* 20 June 2013 | |
* [email protected] | |
* | |
*/ | |
$count =3; // how many events to display | |
if ( isFuture("15 September 2013") && ( $count > 0 ) ) | |
{ | |
$count = $count -1; /* we displayed an event, so de-increment $count */ ?> | |
<p>Exhibition opens to the public | |
</br><strong>Saturday 14 September</strong> | |
<br>1.15pm | |
<br>Price: <strong>free</strong> | |
</p><?php | |
} | |
if ( isFuture("16 September 2013") && ( $count > 0 ) ) | |
{ | |
$count = $count -1; ?> | |
<p>Event two | |
</br><strong>Saturday 16 September</strong> | |
<br>1.15pm | |
<br>Price: <strong>free</strong> | |
</p><?php | |
} | |
if ( isFuture("17 September 2013") && ( $count > 0 ) ) | |
{ | |
$count = $count -1; ?> | |
<p>Event three | |
</br><strong>Saturday 17 September</strong> | |
<br>1.15pm | |
<br>Price: <strong>free</strong> | |
</p><?php | |
} | |
/** | |
* | |
* Is a date in the future | |
* @param string $date A date in text format eg. "14 September 2013" | |
* @return boolean | |
* | |
*/ | |
function isFuture($date){ | |
// include today | |
return (strtotime($date) >= strtotime("now") ) ; | |
} | |
// Next action | |
// Rewrite with a nested array and loop, for sanity | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment