Jump to content

[SOLVED] Mysql php colour conditional format....


Recommended Posts

Hello there guys n girls....

 

This one is something of something i need help on...

 

I have a table which has the following columns.

 

namechannel  = values = varchar

agg              = values = 1 or 0

pseudo        = values = 1 or 0

 

now what i want to do in php is to list all the namechannels and say for example:

 

one row = namechannel and also agg = 1  ( i want the namechannel to be blue)

one row = namechannel and also pseudo = 1 ( i want the namechannel to be green)

one row = namechannel and also pseudo and agg = 0 ( i want the namechannel to be red)

 

 

I have had a look about but cant find the functionality for this and would really would appreciate some help on this please.

 

Thanks!

 

Anil Vaghela

This is what i did.....

 

 

<table border="1" >

  <tr>

   

    <td><div align="center" class="style3">Name Ch</div></td>

<td><div align="center" class="style3">Level</div></td>

  </tr>

  <?php do {

  if ($row_channels['level']=="-1") { $SPACE="";}

  if ($row_channels['level']=="0") { $SPACE="--";}

  if ($row_channels['level']=="1") { $SPACE="----";}

  if ($row_channels['level']=="2") { $SPACE="------";}

  if ($row_channels['level']=="3") { $SPACE="--------";}

  if ($row_channels['level']=="4") { $SPACE="----------";}

  if ($row_channels['level']=="5") { $SPACE="------------";}

//else { $SPACE="";}

 

//$agg = $row_channels['agg'];

//$pseudo = $row_channels['pseudo'];

//$site = $row_channels['site'];

 

 

  if($row_channels['agg']=="1") { $color = "blue"; }

  if($row_channels['pseudo'] == "1"){ $color = "green"; }

  elseif($row_channels['agg'] == "0" AND $row_channels['pseudo'] == "0"){ $color = "red";}

else {$color = "black";}

  ?>

  <tr>

      <td><span class="style3" style="color:<?=$color?>"><?php echo $SPACE.''.$row_channels['name_ch']; ?></span></td>   

<td><span class="style3" style="color:<?=$color?>"><?php echo $row_channels['level'];?></span></td>

  </tr>

 

  <?php } while ($row_channels = mysql_fetch_assoc($channels)); ?>

</table>

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.