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 9021615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:17:50+00:00 2026-06-16T05:17:50+00:00

I have a PHP index page where data from an array is being displayed

  • 0

I have a PHP index page where data from an array is being displayed inside <div>‘s on top of a picture. I want the <div>‘s to change color based on the content inside it.

The idea is this:

I have Customer   -    Date    -    Due in

The array I mean has a structure like the following:

Array(
   [0] => array('customer' => 'John', 'date' => '2012-05-11', 'due' => 9),
   [1] => array('customer' => 'Hess', 'date' => '2011-12-11', 'due' => 5),
   [2] => array('customer' => 'Mrac', 'date' => '2012-06-18', 'due' => 3)
)

Due in shows a number of days – I want the <div> to be red if the number inside it is 5 or lower.

Any help would be greatly appreciated.

  • 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-16T05:17:52+00:00Added an answer on June 16, 2026 at 5:17 am

    Within the php code, give the div a different class if “Due in” is less than or equal to 5.
    So in your PHP, when you’re looping through your array:

    <?php 
      echo "<div";
      if($myArray[i]['due'] <= 5){ echo " class='dueSoon'"; }
      echo "> $myArray[i]['customer'] - $myArray[i]['date'] - $myArray[i]['due'] </div>";
    ?>
    

    so that the following gets output when there’s less than 5 days:

    <div class="dueSoon"> ... </div>
    

    And then css:

    .dueSoon { background-color:red; }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have my index.php page and just afrer my header i want to include
I have the following link on index page <td align=center><a href=../athena/admin/update.php?id=' . $data [keyword]
I have a php page that pulls data from a mysql database based on
I have a index.php page that is the main page. All pages are included
I have an index page index.php , and when the user clicks on a
i have a question, i have a index.php page that is the intro of
I have the following scenario. I have a index.php page with the following JQuery
I have a page index.php that uses a modal to upload files. After those
I have a page index.php where i have a link called add_users.php. In add_users.php,
I have a function that I use on index.php page and I would like

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.