Jump to content

[SOLVED] Colour from a database


almightyegg

Recommended Posts

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

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

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.