almightyegg Posted April 5, 2007 Share Posted April 5, 2007 I've set different ranks to have different colours: rank1 = white etc... the colour of a rank is done like this in my table: rank1 - title of rank rank2 - title of rank rank1color - color of rank rank2color - color or rank I've set them all to FFFFFF yet the ranks are appearing black <? $society = mysql_query("SELECT * FROM clutch WHERE id='$player[clutch]'"); $soc2 = mysql_fetch_array($society); $mif = $player['rank']; ?> Society: <? echo "<a href=http://www.lordoftheabyss.com/society/societyhome.php?id=$soc2[id]>$soc2[name]</a><br>"; ?> Rank: <? echo "<font color=\"#$soc2[$mifcolor]\">$soc2[$mif]</font><br>"; ?> Any ideas? Link to comment https://forums.phpfreaks.com/topic/45756-solved-colour-from-a-database/ Share on other sites More sharing options...
kenrbnsn Posted April 5, 2007 Share Posted April 5, 2007 Did you look at the generated HTML to see what you're writing out? Ken Link to comment https://forums.phpfreaks.com/topic/45756-solved-colour-from-a-database/#findComment-222271 Share on other sites More sharing options...
almightyegg Posted April 5, 2007 Author Share Posted April 5, 2007 <font color="#"> So it is reading it as $mifcolor not as $mif color (color directly after the $mif but it isn't part of the variable) I don't know how to fix it Link to comment https://forums.phpfreaks.com/topic/45756-solved-colour-from-a-database/#findComment-222278 Share on other sites More sharing options...
kenrbnsn Posted April 5, 2007 Share Posted April 5, 2007 Change this line: Rank: <?php echo "<font color=\"#$soc2[$mifcolor]\">$soc2[$mif]</font><br>"; ?> to Rank: <?php echo '<font color="#' . $soc2[$mif . 'color'] . '>$soc2[$mif]</font><br>'; ?> If I were doing this code, I wouldn't jump out of PHP and I would use the <span> tag instead of the <font> tag: <?php $society = mysql_query("SELECT * FROM clutch WHERE id='$player[clutch]'"); $soc2 = mysql_fetch_assoc($society); $mif = $player['rank']; echo 'Society: <a href="http://www.lordoftheabyss.com/society/societyhome.php?id=' . $soc2['id'] . '">' . $soc2['name'] . '</a><br>'; echo 'Rank: <span style="color:#' . $soc2[$mif . 'color'] . '">' . $soc2[$mif] . '</font><br>'; ?> Ken Link to comment https://forums.phpfreaks.com/topic/45756-solved-colour-from-a-database/#findComment-222286 Share on other sites More sharing options...
almightyegg Posted April 5, 2007 Author Share Posted April 5, 2007 echo '<font color="#' . $soc2[$mif . 'color'] . '">$soc2[$mif]</font><br>'; it's almost there... it now echoes out the right colour of $soc2[$mif] but doesn't echo what $soc[$mif] is... So on the page it is: <font color="#FFFFFF">$soc2[$mif]</font> It should be: <font color="#FFFFFF">Co-Leader</font> Link to comment https://forums.phpfreaks.com/topic/45756-solved-colour-from-a-database/#findComment-222376 Share on other sites More sharing options...
kenrbnsn Posted April 5, 2007 Share Posted April 5, 2007 Just missed some concatenation operators: <?php echo '<font color="#' . $soc2[$mif . 'color'] . '">' . $soc2[$mif] . '</font>'; ?> Ken Link to comment https://forums.phpfreaks.com/topic/45756-solved-colour-from-a-database/#findComment-222426 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.