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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Font Colour with PHP

Status
Not open for further replies.

Sitehelp

Technical User
Feb 4, 2004
142
GB
How can I change the font colour using PHP, say if I had the code:

<?php
if ($HTTP_GET_VARS['category'] == &quot;HARDWARE FAULT&quot;)
$Priority = &quot;Amber&quot;;
?>

I bring up the variable $priority in a txt box within a form later on. I want the colour to actually be an amber colour if possible but as its in PHP I am unsure how to do this. Cheers all!
 
Actually just one other quick question )as well as the other just asked) any idea why the date is not getting recognised in my form. I get a message saying &quot;Date cannot be Null&quot; however, it is not null. I have PHP code that calculates the date and puts it in automtically but it doesnt seem to regester the inputted date when submitted. The date appears in the text box fine?????? confused!

My code is:
<?php
$today = date('d-m-Y');
?>

It is supposed to then get stored in a record in my DB on clicking 'Submit'. Cheers again!
 
wouldn't you need to get the hex color? #...

you would need to do
Code:
<?php echo(&quot;<font color=$priority>Stuff</font>&quot;);

gd luck


Martin

Computing help and info:

 
If you want to keep the date or time when something was submitted just use the SQL statement and set that column to NOW(). No need to involve PHP and posting of date etc.

About the color:
This is a HTML question more than it is a PHP question. It is only circumstancial that you use PHP so generate the HTML.
What should have the color? You don't state that.
I suggest, whatever it is, you link your page to a CSS style sheet that defines a class &quot;amber&quot; and apply that class attribute to the item you want to format.
 
thanks! The text saying Red, amber or green should be the same colour as what they say (if that makes sense), i.e. the text &quot;green&quot; should also be the colour 'green' etc... the reason I say I want to do this in PHP is that they are part of a PHP IF statement:

<?php
if ($HTTP_GET_VARS['category'] == &quot;HARDWARE FAULT&quot;)
$Priority = &quot;Amber&quot;;
?>

etc.... for each colour. cheers!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top