Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing Background Colour dependant on date

Status
Not open for further replies.

mcmon999

IS-IT--Management
Mar 3, 2005
21
GB
Hi,

i've created a php frontend, that displays a table of data which contains tasks and dates, i need to change the background colour of the cells dependant on how old the tasks are.

Does anyone know how i should do this or of any threads that would be useful?

Thanks in advance.
 
First edit your script so that it includes a <STYLE>...</STYLE> section in the head of the HTML document it outputs. That <STYLE> section should include sufficient CSS information to define the color classes you want to use.

Then set up sufficient code in your script to output the HTML information necessary to implement your colors. Something like the non-working pseudocode:

Code:
print '<div class="';
$age = HowManyDaysAgo($the_date);
switch (-1)
{
   case ($age > 90):
      print '<90-day class name>';
      break;

   case ($age > 30 || $age < 90)
      print '<30-to-90-day class name';
      break;

   case ($age < 30)
      print '<less-than-30-day class name>';
      break;
}

print '">' . $the_text_to_output . '<div>';

I have used a <DIV> tag in my example pseudocode. Your output might include table tags onto which style classnames can be appended.



Want the best answers? Ask the best questions! TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top