Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Feb 2005
    Posts
    663
    Thanks
    5
    Thanked 14 Times in 14 Posts

    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]." '

  • #2
    New Coder
    Join Date
    Sep 2006
    Posts
    32
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Here you go:

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

  • #3
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    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]." '

  • #4
    Regular Coder
    Join Date
    Feb 2005
    Posts
    663
    Thanks
    5
    Thanked 14 Times in 14 Posts
    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.

  • #5
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    What's it show in the source? Is there a class made named what's shown? What's the css for that class?

  • #6
    Regular Coder
    Join Date
    Feb 2005
    Posts
    663
    Thanks
    5
    Thanked 14 Times in 14 Posts
    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>"


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •