p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: How to adjust the font property


Message #1 by "Dominic Savio" <kselvanathan@y...> on Fri, 27 Sep 2002 20:10:40
I would like to adjust the font property the colour. The colour will change
depending on the message. That's where my problem lies.

<?php
$Text="right";
if ($Text == "right")
{
$message= "<font color="#FF0000">Please click on the back button on your
browser and fill out all the boxes marked with the red asterix.</font>";
echo $message;
}
else
{
$message= "<font color="#666666">Please click on the back button on your
browser and fill out all the boxes marked with the red asterix.</font>";
echo $message;
}
?>

I would prefer something like this, where the colour can change at run time.

<?php
$cl="#FF0000"   //this can be changed at run time
<font size="2" face="Verdana, Arial, Helvetica, sans-serif" color="<?php
$cl ?>">
<?php
echo $message;
?>

Thanks for your help.

Selva
Message #2 by "Gerry Vandermaesen" <gerry@a...> on Fri, 27 Sep 2002 21:05:21 +0200
You have to use <?php echo($cl); ?> to display the contents of the
variable.

-----Original Message-----
From: Dominic Savio [mailto:kselvanathan@y...] 
Sent: vrijdag 27 september 2002 20:11
To: beginning php
Subject: [beginning_php] How to adjust the font property


I would like to adjust the font property the colour. The colour will
change depending on the message. That's where my problem lies.

<?php
$Text="right";
if ($Text == "right")
{
$message= "<font color="#FF0000">Please click on the back button on your
browser and fill out all the boxes marked with the red asterix.</font>";
echo $message; } else { $message= "<font color="#666666">Please click on
the back button on your browser and fill out all the boxes marked with
the red asterix.</font>"; echo $message; } ?>

I would prefer something like this, where the colour can change at run
time.

<?php
$cl="#FF0000"   //this can be changed at run time
<font size="2" face="Verdana, Arial, Helvetica, sans-serif" color="<?php
$cl ?>"> <?php echo $message; ?>

Thanks for your help.

Selva

Message #3 by Krister <krister@m...> on Fri, 27 Sep 2002 23:02:03 +0200
On 27/09/02 20:10, "Dominic Savio" <kselvanathan@y...> wrote:

> I would like to adjust the font property the colour. The colour will change
> depending on the message. That's where my problem lies.
> 
> <?php
> $Text="right";
> if ($Text == "right")
> {
> $message= "<font color="#FF0000">Please click on the back button on your
> browser and fill out all the boxes marked with the red asterix.</font>";
> echo $message;
> }
> else
> {
> $message= "<font color="#666666">Please click on the back button on your
> browser and fill out all the boxes marked with the red asterix.</font>";
> echo $message;
> }
> ?>
> 
> I would prefer something like this, where the colour can change at run time.
> 
> <?php
> $cl="#FF0000"   //this can be changed at run time
> <font size="2" face="Verdana, Arial, Helvetica, sans-serif" color="<?php
> $cl ?>">
> <?php
> echo $message;
> ?>
> 
> Thanks for your help.
> 
> Selva

Hi Selva

I had some difficulties to understand what you want, but in case you want
that the color is gray if the answer is correct and otherwise red, you could
use following:

<?php
    // $text is your correct answer and
    // $HTTP_POST_VARS['field'] is the response from the field
    $color = (  $text == $HTTP_POST_VARS['field'] ) ? "#666666" : "#FF0000";
?>
<font color="<?php echo $color; ?>">Some text in gray or red</font>

Krister


Message #4 by "jorge" <jorge@d...> on Sun, 29 Sep 2002 09:25:30 -0500
Create a variable
if(condition one){$font_color="#......";}
elseif(condition two){$font_color="#......";}
else{$font_color=...;}
palce it in the font tag
<font color =\"$font_color\">

Saludos

Jorge Cordero
----- Original Message -----
From: "Krister" <krister@m...>
To: "beginning php" <beginning_php@p...>
Sent: Friday, September 27, 2002 4:02 PM
Subject: [beginning_php] Re: How to adjust the font property


> On 27/09/02 20:10, "Dominic Savio" <kselvanathan@y...> wrote:
>
> > I would like to adjust the font property the colour. The colour will
change
> > depending on the message. That's where my problem lies.
> >
> > <?php
> > $Text="right";
> > if ($Text == "right")
> > {
> > $message= "<font color="#FF0000">Please click on the back button on your
> > browser and fill out all the boxes marked with the red asterix.</font>";
> > echo $message;
> > }
> > else
> > {
> > $message= "<font color="#666666">Please click on the back button on your
> > browser and fill out all the boxes marked with the red asterix.</font>";
> > echo $message;
> > }
> > ?>
> >
> > I would prefer something like this, where the colour can change at run
time.
> >
> > <?php
> > $cl="#FF0000"   //this can be changed at run time
> > <font size="2" face="Verdana, Arial, Helvetica, sans-serif" color="<?php
> > $cl ?>">
> > <?php
> > echo $message;
> > ?>
> >
> > Thanks for your help.
> >
> > Selva
>
> Hi Selva
>
> I had some difficulties to understand what you want, but in case you want
> that the color is gray if the answer is correct and otherwise red, you
could
> use following:
>
> <?php
>     // $text is your correct answer and
>     // $HTTP_POST_VARS['field'] is the response from the field
>     $color = (  $text == $HTTP_POST_VARS['field'] ) ? "#666666" :
"#FF0000";
> ?>
> <font color="<?php echo $color; ?>">Some text in gray or red</font>
>
> Krister
>
>
>
>



  Return to Index