Help with time-based conditionals
Written By maryann on Jan. 26, 2008.
2 Comments
Report Note
+ Clip This
I'm in WordPress (don't know if that matters for this particular code) and I'm trying to display various different things between certain dates, and something else outside of those dates.
Here's what I have so far:
<?php $eventheader = getdate() ?>
<?php if ($eventheader[mon] = 2 && $eventheader[mday] > 12 && $eventheader[mday] < 22){ ?>
<?php include (TEMPLATEPATH . '/event-winter.php'); ?> <!-- Winter Cup -->
<?php if ($eventheader[mon] = 3 && $eventheader[mday] > 4 && $eventheader[mday] < 14){ ?>
<?php include (TEMPLATEPATH . '/event-margutti.php'); ?> <!-- Margutti Trophy -->
<?php if ($eventheader[mon] = 3 && $eventheader[mday] > 4 && $eventheader[mday] < 14){ ?>
<?php include (TEMPLATEPATH . '/event-wsk1.php'); ?> <!-- WSK Round 1 -->
<?php } else { ?>
<?php include (TEMPLATEPATH . '/poll.php'); ?> <!-- Any other time -->
<?php } ?>
As anyone familiar with PHP can probably see, it works with just either event-winter.php or poll.php, but I'm the noobiest of noobs and I don't know how to make it choose from a whole list. Does anyone else know or can point me to an informative link?

oniTony
Written Jan. 27, 2008 / Report /
Does this even work? There are 4 opening { but only 2 closing }. Try indenting your code to see the logic flow of the if statements.
maryann
Written Jan. 27, 2008 / Report /
Yes, I don't know how to close the other two. I can see the logic (or lack of it in this case!) in the ifs I just really know very little about PHP.