Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-24-2010, 03:15 AM   PM User | #1
pagedrop
New Coder

 
Join Date: Oct 2005
Posts: 61
Thanks: 12
Thanked 0 Times in 0 Posts
pagedrop is an unknown quantity at this point
Change cell background

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
pagedrop is offline   Reply With Quote
Old 03-24-2010, 03:31 AM   PM User | #2
DJCMBear
Senior Coder

 
DJCMBear's Avatar
 
Join Date: Mar 2010
Location: United Kindom
Posts: 1,173
Thanks: 14
Thanked 136 Times in 136 Posts
DJCMBear is on a distinguished road
Quote:
Originally Posted by pagedrop View Post
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
PHP Code:
$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";

__________________
Official BinPress hand picked coder.
For anyone worried about SQL injection go have a look at my small yet powerful script here.
Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
I am 1 of 65,608 people to get a Pebble Watch :P
DJCMBear is offline   Reply With Quote
Old 03-24-2010, 04:15 PM   PM User | #3
pagedrop
New Coder

 
Join Date: Oct 2005
Posts: 61
Thanks: 12
Thanked 0 Times in 0 Posts
pagedrop is an unknown quantity at this point
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..
pagedrop is offline   Reply With Quote
Old 03-24-2010, 06:31 PM   PM User | #4
DJCMBear
Senior Coder

 
DJCMBear's Avatar
 
Join Date: Mar 2010
Location: United Kindom
Posts: 1,173
Thanks: 14
Thanked 136 Times in 136 Posts
DJCMBear is on a distinguished road
Ok then heres the code:
PHP 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
__________________
Official BinPress hand picked coder.
For anyone worried about SQL injection go have a look at my small yet powerful script here.
Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
I am 1 of 65,608 people to get a Pebble Watch :P
DJCMBear is offline   Reply With Quote
Old 02-01-2011, 02:33 AM   PM User | #5
mehidy
New Coder

 
Join Date: Jan 2011
Location: Bangladesh
Posts: 73
Thanks: 4
Thanked 0 Times in 0 Posts
mehidy is an unknown quantity at this point
Quote:
Originally Posted by DJCMBear View Post
Ok then heres the code:
PHP 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".
mehidy is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:27 AM.


Advertisement
Log in to turn off these ads.