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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Aug 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to Target a Specific PHP Element with CSS?

    The following is part of a larger Wordpress php script that works as it should. What I simply need to do is target the specific element "$speaker" with a CSS class "speakerTitle" that I've already defined to give it a different color, etc. I don't want to add another class to the "td" since I only want to target that element. What's the best way to do that without mucking up the code? After "echo", both $speaker and $title have the same default styles, so I just want to isolate $speaker. Any help on what I'm guessing is a really simple solution would be fantastic!


    Code:
    <td class="colw col-<?php echo $l?> ">
    <div> 
      <?php }
            
    	  foreach ($session_array as $session_id) { ?>
    	  <?php 
              
              $session_location = get_session_location( $session_id); 
              $title = get_session_title($session_id);
              
              if($location->name == $session_location)
              {
                  
                  $speaker = get_session_speaker($session_id); 
                  
                  echo  $speaker.'<br/>'.$title; 
              }
          }	
                                           
        ?>
        </div>
    </td>

  • #2
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,395
    Thanks
    8
    Thanked 1,078 Times in 1,069 Posts
    echo '<span class=\"speakerTitle\">'.$speaker.'</span><br/>'.$title;

  • #3
    New to the CF scene
    Join Date
    Aug 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mlseim View Post
    echo '<span class=\"speakerTitle\">'.$speaker.'</span><br/>'.$title;
    OK, so I tried this at first and it didn't work and then I took out the 2 forward slashes and it worked perfectly. Maybe a Wordpress thing? Anyway, thanks, this got me rockin!

    Code:
    echo '<span class="speakerTitle">'.$speaker.'</span><br/>'.$title;

  • #4
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,395
    Thanks
    8
    Thanked 1,078 Times in 1,069 Posts
    my bad .. you are right, the slashes were not needed. I forgot that you were using single quotes for encasing the echo, therefore, slashes not needed for double quotes.


  •  

    Tags for this Thread

    Posting Permissions

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