Jump to content

Font color change


sunman4008
 Share

Recommended Posts

Hello,The variable $podatek has the value contained in a database cell. I want to change the font color for the podatek variable. Not sure how to do it. Any help would be greatly appreciated. I thought I could add <font color=#0000ff /font> but that didnt' work.-Manesh $field['output_script'] .= "<td "; if($this->_config->columnWidth[$j]!=0) $field['output_script'] .= " width=\"".$this->_config->columnWidth[$j]."\" "; if($this->_config->lineHeight!=0) $field['output_script'] .= " height=\"".$this->_config->lineHeight."\" "; $field['output_script'] .= "><span class=\"field\"> "; if($linkType=='0'){ $field['output_script'] .= $podatek; } else{ $link=$this->_data[$i][$this->_config->link[2*$j+1]]; $field['output_script'] .=$this->createLink($linkType,$link, $podatek); } $field['output_script'] .= "</span></td>";

Link to comment
Share on other sites

Hello,So, it should be this? if($linkType=='0'){ $field['output_script'] .= $podatek; $field['output_script'].= "<style type="text/css">.field {color:#0000ff }</style>"; Sorry, I do C++ programming and everything else but this is the first time for php or any web programming. Not sure of the syntax.-Manesh

Link to comment
Share on other sites

no, no you just add the code i supplied in the <head> </head> of you web page,<head><style type="text/css">.field {color:#0000ff }</style> </head>OR create css (test.css) page add .field {color:#0000ff }to it, and then add link to it into the <head> tags<head><link rel="stylesheet" href="test.css" type="text/css" /></head>

Link to comment
Share on other sites

Hello,the problem with that is all the text changes to this color. The variable is actually in a for loop because it has represents different column/row in a database. What I am trying to do is when the string in a cell is a certain value, I want to change the font color based on the value. Therefore, $field['output_script'] .= $podatek; represents the cell in the database.-Manesh

Link to comment
Share on other sites

then all you have to do is assign a class to an specific valueif ($value==0){<span class="fieldcol1">}else if ($value>0 && <100){<span class="fieldcol2">}else{<span class="fieldcol3">}OR even betterif ($value==0){$fieldcol="fieldcol1";}else if ($value>0 && <100){$fieldcol="fieldcol2";}else{$fieldcol="fieldcol3";}$field['output_script'] .= " class='".$fieldcol."' ";then you can control the colour by changing css styling rather than editing the php coding each time.fieldcol1 {color:#0000ff; }.fieldcol2 {color:#ff00ff; }.fieldcol3 {color:#00ff00; }anyway heres answer to you posted question$field['output_script'] .= " style='color:#00FF00;' ";

Edited by dsonesuk
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...