vbcoach Posted April 11, 2011 Share Posted April 11, 2011 Hello. Racking my brains here, having trouble with this. Running a sports league, trying to get the output of one variable at a different font color OR insert a simple check mark graphic. Either way I am stuck. I am a bit out of practice here. Here is the code. Where is says echo ( Locked) is where I would like to either have locked in a color, say green or red - or insert check mark symbol. <?php $last = -1; while($team = mssql_fetch_assoc($res)) { if ($last != $team['l_id']) { $last = $team['l_id']; echo "<br><span class=\"dk_greyTxt\" style=\"font-size: 14px\"><strong>$team[night] night, $team[type] $team[size]s $team[division]</strong></span><br><br>"; } echo "<strong>$team[teamname] - ($team[shirtcolor] shirts)</strong><br> RegDate: $team[reg_start]<br>RegDone: $team[reg_done]"; $cpt = mssql_query("SELECT firstname, lastname, shirtsize, feepaid, feememo FROM captain WHERE c_id = $team[captain]",$conn); $c = mssql_fetch_assoc($cpt); if($team["locked"] == 1) { echo " (Locked)"; } else { echo " "; } echo "<br>"; Quote Link to comment https://forums.phpfreaks.com/topic/233344-how-to-color-code-certain-words-of-php-database-output/ Share on other sites More sharing options...
spiderwell Posted April 11, 2011 Share Posted April 11, 2011 just wrap the echoed output in a span tag with a css class attached or inline style defination Quote Link to comment https://forums.phpfreaks.com/topic/233344-how-to-color-code-certain-words-of-php-database-output/#findComment-1199975 Share on other sites More sharing options...
vbcoach Posted April 11, 2011 Author Share Posted April 11, 2011 Ok, I understand that. but when I tried, I received an error. Do I wrap it inside the quotes? Can you give me an example please? Thanks a bunch Quote Link to comment https://forums.phpfreaks.com/topic/233344-how-to-color-code-certain-words-of-php-database-output/#findComment-1200181 Share on other sites More sharing options...
spiderwell Posted April 11, 2011 Share Posted April 11, 2011 echo "<span class='something'>(locked)<span>"; echo "<span style='color:red;'>(locked)<span>"; Quote Link to comment https://forums.phpfreaks.com/topic/233344-how-to-color-code-certain-words-of-php-database-output/#findComment-1200185 Share on other sites More sharing options...
vbcoach Posted April 11, 2011 Author Share Posted April 11, 2011 UNFORTUNATELY, no working if($team["locked"] == 1) { echo "<span style='color:red;'>(locked)</span>"; else { echo " "; } echo "<br>"; I get this error: Parse error: parse error, unexpected T_ELSE in E:\... php on line 61 Quote Link to comment https://forums.phpfreaks.com/topic/233344-how-to-color-code-certain-words-of-php-database-output/#findComment-1200187 Share on other sites More sharing options...
vbcoach Posted April 11, 2011 Author Share Posted April 11, 2011 Ok, reloaded the code, now works BUT ***EVERYTHING*** past is now in red. I only wanted the results "(Locked)" to be in red. Nothing else. Were getting close. Help? Quote Link to comment https://forums.phpfreaks.com/topic/233344-how-to-color-code-certain-words-of-php-database-output/#findComment-1200188 Share on other sites More sharing options...
spiderwell Posted April 11, 2011 Share Posted April 11, 2011 this is no longer a php issue, lol the red should only effect the spanned text. can you post all the relevant code Quote Link to comment https://forums.phpfreaks.com/topic/233344-how-to-color-code-certain-words-of-php-database-output/#findComment-1200192 Share on other sites More sharing options...
vbcoach Posted April 11, 2011 Author Share Posted April 11, 2011 FIXED! Just needed to do a </span> and I now have what I needed! Thanks for the refresher team! Much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/233344-how-to-color-code-certain-words-of-php-database-output/#findComment-1200197 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.