I would normally do this sort of thing in jQuery, but this will require a server side touch. I am new to PHP and need assistance writing a basic script that will take in a numerical month the_time('m') and I simply wish to say if it equals 01 then echo "#000" and then loop through the other months 02, 03 ,04, so on and have them echo different hex codes if the month is equal.
Forgive my crude and incorrect code, but I thought this would help visualize the solution I am working towards.
style="background: #
<?php
if(the_time('m') == "01") {
echo "000";
} else if (the_time('m') == "02"){
echo "111";
} // so on through 12
?>
"
Any help would be greatly appreciated. Thank you.
EDIT
The while loop code I am currently inside:
<?php while ( have_posts() ) : the_post(); ?>
<?php
$code = "f5f5f5"; // Set default
$month = the_time('m');
switch ($month) {
case "01" :
$code = "f5f5f5";
break;
case "02" :
$code = "f3f3f3";
break;
case "03" :
$code = "f1f1f1";
break;
case "04" :
$code = "efefef";
break;
}
?>
<li id="event_<?php the_time('m_d_Y') ?>" style="background: #<?php echo $code ?>;">
I wouldn’t really go down that path, but I’d do something like: