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.
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:
so that the following gets output when there's less than 5 days:
And then css:
We will suppose that your array is named as results
CSS
The following is the PHP code that you have to use to print out this array.
In your PHP code, check for this condition, if the condition is being met, then add a css class to that div (for which the condition is being satisfied).
Define the CSS class in your CSS file.