anilvaghela Posted August 14, 2009 Share Posted August 14, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/170253-solved-mysql-php-colour-conditional-format/ Share on other sites More sharing options...
aschk Posted August 14, 2009 Share Posted August 14, 2009 In pseudocode... if(agg==1) { $color = blue } elseif(pseudo == 1){ $color = green } elseif(agg == 0 AND pseudo == 0){ $color = red } Quote Link to comment https://forums.phpfreaks.com/topic/170253-solved-mysql-php-colour-conditional-format/#findComment-898103 Share on other sites More sharing options...
anilvaghela Posted August 14, 2009 Author Share Posted August 14, 2009 Thanks but how do i build it into a sql script to show the results in php? Quote Link to comment https://forums.phpfreaks.com/topic/170253-solved-mysql-php-colour-conditional-format/#findComment-898124 Share on other sites More sharing options...
anilvaghela Posted August 20, 2009 Author Share Posted August 20, 2009 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> Quote Link to comment https://forums.phpfreaks.com/topic/170253-solved-mysql-php-colour-conditional-format/#findComment-902597 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.