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? Quote 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 Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.