kevincro Posted October 23, 2007 Share Posted October 23, 2007 Is it possible to display table data using a while loop, yet have each output row with a certain bg color depending on a value within that row. For instance, if I'm dislaying the incomes of various businesses, I want to show the business with a positive income with a green background, and the business with a negative income with a red background. Is this possible? Link to comment https://forums.phpfreaks.com/topic/74526-background-colors-on-display-pages/ Share on other sites More sharing options...
cooldude832 Posted October 23, 2007 Share Posted October 23, 2007 yup. <?php while(){ echo "<tr "; if($var === 1{echo "class=\"positive\";} elseif($var === 2){echo "class=\"negative\";} else{echo "class=\"normal\";} echo ">"; //More output } ?> Just define the classes in your css doc Link to comment https://forums.phpfreaks.com/topic/74526-background-colors-on-display-pages/#findComment-376651 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.