phpretard Posted February 17, 2009 Share Posted February 17, 2009 I need to take an id number in a row and have php decide if it is an even or odd number. This is for asthetics only. If the row is odd it will display a slightly different color background. <? $result = mysql_query("SELECT * FROM feeschedule"); while($row = mysql_fetch_array($result)) { $id=$row['id']; $appType=$row['appType']; echo" <tr ***I AM USING IT HERE TO DISPLAY A DIFFERENT COLOR BACKGROUND***> <td class='displayText'>$appType</td> <td class='displayText'>$<input type='' name='24hr$id' value='' /></td> <td class='displayText'>$<input type='' name='3days$id' value='' /></td> <td class='displayText'>$<input type='' name='7days$id' value='' /></td> </tr> "; } ?> Thanks PHP Freaks! Quote Link to comment https://forums.phpfreaks.com/topic/145615-solved-math-divisible-by-2/ Share on other sites More sharing options...
Zane Posted February 17, 2009 Share Posted February 17, 2009 echo" Quote Link to comment https://forums.phpfreaks.com/topic/145615-solved-math-divisible-by-2/#findComment-764474 Share on other sites More sharing options...
allworknoplay Posted February 17, 2009 Share Posted February 17, 2009 echo" <tr style='background-color:", $row['id'] % 2 ? "#000000" : "#FFFFFF", "> That's an awesome conditional. Mine is the same but it's 3-5 lines.... I will have to use this one from now on.... Quote Link to comment https://forums.phpfreaks.com/topic/145615-solved-math-divisible-by-2/#findComment-764476 Share on other sites More sharing options...
phpretard Posted February 17, 2009 Author Share Posted February 17, 2009 Sweet! Quote Link to comment https://forums.phpfreaks.com/topic/145615-solved-math-divisible-by-2/#findComment-764477 Share on other sites More sharing options...
Prismatic Posted February 17, 2009 Share Posted February 17, 2009 me so slow Quote Link to comment https://forums.phpfreaks.com/topic/145615-solved-math-divisible-by-2/#findComment-764478 Share on other sites More sharing options...
Zane Posted February 18, 2009 Share Posted February 18, 2009 the less lines the better Quote Link to comment https://forums.phpfreaks.com/topic/145615-solved-math-divisible-by-2/#findComment-765018 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.