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
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

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.