CSS and variables

CSS and variables

am 20.11.2009 17:12:11 von Phil Matt

De-lurking here.

I'm trying, with no success, to use some CSS styling on my PHP output.

Here's the code I want to style:

echo ''.$row[0].''.$row[1].'

I want to use a CSS style for the second cell, picking up the style
from the value of a variable. I tried this:

$newcolor = "color: red";

'.$row[1].'

But it doesn't work. No problem with th "spacer" class, works fine. I
just can't get the syntax for pulling a CSS style from a PHP var.

TIA for your help!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: CSS and variables

am 20.11.2009 17:19:56 von Richard

Hi,

> $newcolor = "color: red";
>
> '.$row[1].'
>
> But it doesn't work. No problem with th "spacer" class, works fine. I just
> can't get the syntax for pulling a CSS style from a PHP var.

You could do this:

$newcolor = 'red';
echo "{$row[1]}";
?>

--
Richard Heyes
HTML5 graphing: RGraph - www.rgraph.net (updated 14th November)
Lots of PHP and Javascript code - http://www.phpguru.org

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: CSS and variables

am 20.11.2009 17:38:30 von LinuxManMikeC

On Fri, Nov 20, 2009 at 9:12 AM, Phil Matt wrote:
> De-lurking here.
>
> I'm trying, with no success, to use some CSS styling on my PHP output.
>
> Here's the code I want to style:
>
> echo ''.$row[0].''.$row[1].'
>
> I want to use a CSS style for the second cell, picking up the style
> from the value of a variable. I tried this:
>
> $newcolor = "color: red";
>
> '.$row[1].'
>
> But it doesn't work. No problem with th "spacer" class, works fine. I just
> can't get the syntax for pulling a CSS style from a PHP var.
>
> TIA for your help!
>

You can't use PHP tags inside a string. You just need to concatenate
the variable into the string you're echoing.
echo ''.$row[0].' style="'.$newcolor.'">'.$row[1].'';

PHP tags may only contain PHP statements. You can't nest additional
PHP tags within. They won't be evaluated.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RES: CSS and variables

am 20.11.2009 17:45:23 von Zechim

Try:

echo '' . $row[1] . '';

-----Mensagem original-----
De: Phil Matt [mailto:admin@philmatt.com]
Enviada em: sexta-feira, 20 de novembro de 2009 14:12
Para: php-general@lists.php.net
Assunto: [PHP] CSS and variables

De-lurking here.

I'm trying, with no success, to use some CSS styling on my PHP output.

Here's the code I want to style:

echo ''.$row[0].''.$row[1].'

I want to use a CSS style for the second cell, picking up the style
from the value of a variable. I tried this:

$newcolor = "color: red";

'.$row[1].'

But it doesn't work. No problem with th "spacer" class, works fine. I
just can't get the syntax for pulling a CSS style from a PHP var.

TIA for your help!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: RES: CSS and variables

am 20.11.2009 21:55:37 von Phil Matt

Jônatas Zechim wrote:
> Try:
>
> echo '' . $row[1] . '';
>
>

Thanks, Jônatas. This was the solution.

Cheers --- Phil

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: RES: CSS and variables

am 21.11.2009 14:56:12 von TedD

This might help:

http://sperling.com/examples/pcss/

Cheers,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php