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! 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" 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.... 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! 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 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 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
Archived
This topic is now archived and is closed to further replies.