Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-24-2007, 06:55 PM   PM User | #1
ptmuldoon
Regular Coder

 
Join Date: Feb 2005
Posts: 659
Thanks: 5
Thanked 14 Times in 14 Posts
ptmuldoon is on a distinguished road
echo span tag help

Can someone tell me how to echo the below code into a span tag?

PHP Code:
<td class="state-<?php echo $player[1]; ?>">
I thought this would be correct, but I haven't gotten it to work yet

PHP Code:
<span style='color:state-".$player[1]." '
ptmuldoon is offline   Reply With Quote
Old 01-24-2007, 07:02 PM   PM User | #2
jlimited
New Coder

 
Join Date: Sep 2006
Posts: 32
Thanks: 5
Thanked 0 Times in 0 Posts
jlimited is an unknown quantity at this point
Here you go:

PHP Code:
echo "<span style='color:state-".$player[1]."'>"
jlimited
jlimited is offline   Reply With Quote
Old 01-24-2007, 07:07 PM   PM User | #3
Nightfire
Senior Coder

 
Nightfire's Avatar
 
Join Date: Jun 2002
Posts: 4,266
Thanks: 6
Thanked 48 Times in 48 Posts
Nightfire is on a distinguished road
It won't work as there is no such colour called 'state-xxxx'.
This is a css problem, not a php one.
PHP Code:
<span class='color:state-".$player[1]." '
__________________
Blue Panda
Website Design | 1 Pound Ads | 'ow much? | Coding Geeks
Nightfire is offline   Reply With Quote
Old 01-24-2007, 07:20 PM   PM User | #4
ptmuldoon
Regular Coder

 
Join Date: Feb 2005
Posts: 659
Thanks: 5
Thanked 14 Times in 14 Posts
ptmuldoon is on a distinguished road
Quote:
Originally Posted by Nightfire View Post
It won't work as there is no such colour called 'state-xxxx'.
This is a css problem, not a php one.
PHP Code:
<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.
PHP Code:
$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; 

Last edited by ptmuldoon; 01-24-2007 at 07:56 PM..
ptmuldoon is offline   Reply With Quote
Old 01-24-2007, 08:40 PM   PM User | #5
Nightfire
Senior Coder

 
Nightfire's Avatar
 
Join Date: Jun 2002
Posts: 4,266
Thanks: 6
Thanked 48 Times in 48 Posts
Nightfire is on a distinguished road
What's it show in the source? Is there a class made named what's shown? What's the css for that class?
__________________
Blue Panda
Website Design | 1 Pound Ads | 'ow much? | Coding Geeks
Nightfire is offline   Reply With Quote
Old 01-24-2007, 09:53 PM   PM User | #6
ptmuldoon
Regular Coder

 
Join Date: Feb 2005
Posts: 659
Thanks: 5
Thanked 14 Times in 14 Posts
ptmuldoon is on a distinguished road
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:
PHP Code:
echo "<span class=\"state-".$player[1]."\">".$player[0]."</span>"
ptmuldoon is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:03 AM.


Advertisement
Log in to turn off these ads.