...

View Full Version : Change cell background



pagedrop
03-24-2010, 03:15 AM
from my mysql database, i have a cell which have words as green, yellow as results.

i was wondering, how could i change that cell background based on the word i get.


thank you

DJCMBear
03-24-2010, 03:31 AM
from my mysql database, i have a cell which have words as green, yellow as results.

i was wondering, how could i change that cell background based on the word i get.


thank you

have a mysql query with somthing like this assuming you want a random color to be called and not alternative colours


$result=mysql_query("SELECT * FROM table ORDER BY REAND() LIMIT 0,1");
while($row = mysql_fetch_array($result)){
$color = $row['collname'];
print "<td style=\"background-color:$color;\"></td>\n";
}

pagedrop
03-24-2010, 04:15 PM
didnt quite help, i need to show green color, if the results from column"Risk" is green, and yellow background if its yellow in that column. etc..

DJCMBear
03-24-2010, 06:31 PM
Ok then heres the code:


$result=mysql_query("SELECT * FROM table");
if(mysql_num_rows($result)){
while($row = mysql_fetch_array($result)){
$risk = strtolower($row['Risk']);
if($risk=='yellow'){
$color = '#FFFF00';
}elseif($risk=='green'){
$color = '#33CC33';
}else{
$color = '';
}}}
print $color;

mehidy
02-01-2011, 02:33 AM
Ok then heres the code:


$result=mysql_query("SELECT * FROM table");
if(mysql_num_rows($result)){
while($row = mysql_fetch_array($result)){
$risk = strtolower($row['Risk']);
if($risk=='yellow'){
$color = '#FFFF00';
}elseif($risk=='green'){
$color = '#33CC33';
}else{
$color = '';
}}}
print $color;


hi i have same question, my data are in number like 0,1,2,5,30,100,200 and so on,i want cell bgcolor in red where data equal or below 30 and data equal or below 60 in yellow and others in green color, plz help me. My colum name is "days to go".



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum