Fluoresce Posted February 18, 2009 Share Posted February 18, 2009 The tiny piece of code below means, if the alias of a person is unavailable in the database, echo the person's name. Otherwise, echo the alias. echo (empty($row['alias']) ? $row['name'] : $row['alias']); If the alias is going to be echoed, I want it to be echoed in bold, red font, so I used a span tag and added a CSS class: echo (empty($row['alias']) ? $row['name'] : "Alias is: <span class=\"boldred\">" . $row['alias']) . "</span>"; It worked. However, when it echoes the name and not the alias, my HTML doesn't validate, because it also echoes the closing span tag. In other words, it either echoes this Alias is: Alias or this Name</span> (of course, you can't see the span tag). Anyone know how I can fix this? Link to comment https://forums.phpfreaks.com/topic/145684-solved-cant-think-of-appropriate-subject-heading-confused/ Share on other sites More sharing options...
jamesnes Posted February 18, 2009 Share Posted February 18, 2009 Carefully look at your parentheses, then you should be able to work out why. Link to comment https://forums.phpfreaks.com/topic/145684-solved-cant-think-of-appropriate-subject-heading-confused/#findComment-764845 Share on other sites More sharing options...
Fluoresce Posted February 18, 2009 Author Share Posted February 18, 2009 Carefully look at your parentheses, then you should be able to work out why. Ah . . . Thanks, Jamesnes! I now see the problem. It should be like this: echo (empty($row['alias']) ? $row['name'] : "Alias is: <span class=\"boldred\">" . $row['alias'] . "</span>"); I appreciate it. Link to comment https://forums.phpfreaks.com/topic/145684-solved-cant-think-of-appropriate-subject-heading-confused/#findComment-764865 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.