Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7865645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:09:01+00:00 2026-06-03T00:09:01+00:00

I would normally do this sort of thing in jQuery, but this will require

  • 0

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 ?>;">
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T00:09:02+00:00Added an answer on June 3, 2026 at 12:09 am

    I wouldn’t really go down that path, but I’d do something like:

    <div class="month-<?php echo strtolower(date('M')) ?>">Howdy</div>
    
    // your CSS file:
    .month-jan { background: #000; }
    .month-feb { background: #FFF; }
    // etc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This kind of code would normally work in PHP, but since the scope is
I don't normally make this sort of question / answer, but figured I'd do
I believe this is how you would normally sort a hash by value: foreach
Normally I would just do this. $str = preg_replace('#(\d+)#', ' $1 ', $str); If
Normaly i would do a delete * from XXX but on this table thats
Normally I would have one junit test that shows up in my integration server
Normally I would just use URL GET parameters but CodeIgniter doesn't seem to like
I am analyzing data from a wind turbine, normally this is the sort of
For databases that don't require any sort of username or password, I normally fetch
When typing code, I would normally close brackets, go back inside, go outside, type

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.