...

View Full Version : echo span tag help



ptmuldoon
01-24-2007, 06:55 PM
Can someone tell me how to echo the below code into a span tag?


<td class="state-<?php echo $player[1]; ?>">

I thought this would be correct, but I haven't gotten it to work yet


<span style='color:state-".$player[1]." '>

jlimited
01-24-2007, 07:02 PM
Here you go:


echo "<span style='color:state-".$player[1]."'>";

jlimited

Nightfire
01-24-2007, 07:07 PM
It won't work as there is no such colour called 'state-xxxx'.
This is a css problem, not a php one.


<span class='color:state-".$player[1]." '>

ptmuldoon
01-24-2007, 07:20 PM
It won't work as there is no such colour called 'state-xxxx'.
This is a css problem, not a php one.


<span class='color:state-".$player[1]." '>


Yes, I realized after I posted, I still need to use the class to get the color. But unfortunately, even though it looks correct to my rookie eyes, the below is still not working correctly.

The query is accurate. It gets and echos the player name fine. Just no css to go with it.

$sql = 'SELECT player, state FROM game_'.$game['id'].' WHERE state != \'inactive\' AND state != \'initial\' AND state != \'dead\' AND state != \'waiting\' AND id != 1';
$player = get_array($sql);
if ($player[0] == $_SESSION['player_name']) {
echo "<span class='state-".$player[1]." '>".$player[0]."</span>";
} else {
echo $player[0];
break;

Nightfire
01-24-2007, 08:40 PM
What's it show in the source? Is there a class made named what's shown? What's the css for that class?

ptmuldoon
01-24-2007, 09:53 PM
Thanks for the tip to look at the source code. I should have known to do that.

The source code was showing:

<span class='state-attacking'>playername</span>

Changing the code to below did the trick:

echo "<span class=\"state-".$player[1]."\">".$player[0]."</span>";



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum