Page 1 of 1

(Solved) ..echo a text with a color stored in a variable?

Posted: Fri Oct 25, 2013 9:08 am
by hybris
I want a system where the username change with their rating.

I created a if - else if block to store different colorvalues in a variable like:

if (rating = 1) { $usrcolor='#FFFF444'; }

the if block is working... if i echo the $usrcolor variable it shows the correct #?????? value.

Now i want to do something like:

echo "<p style=\"font-color:$usrcolor; \">$username</p>";

but I cannot get it to work.

I think I messed up with the " or forgot some dot (like .$xxx)...

I tried alot of different ways to echo it but either i get it in black color or it wont echo at all..

please help I'm getting seriously frustrated heh.

Thanks

Re: How do you echo a text with a color stored in a variable

Posted: Fri Oct 25, 2013 9:27 am
by hybris
Solved it myself :)

echo "<span style=color:$namecolor class=\"label-$username\">$username</span>";