note 60353 added to function.fmod
| From: | JohnCraig at osu1 dot php dot net | Date: | Wed, 04 Jan 2006 17:42:38 +0000 |
| Subject: | note 60353 added to function.fmod | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-101206@lists.php.net to get a copy of this message | ||
I have been using fmod() to determine whether a number is odd or even. For example;
When printing HTML table rows, I would like every-other row to have a colored background for easy
reading. Here's the code:
<? if (fmod($x, 2) == "") { echo 'bgcolor="#F6F6F6"'; } ?>
Just stick that line inside the <tr> tag and you're all set!
Also, if you would like the even rows to be another color, add the else statement as such;
<? if (fmod($x, 2) == "") { echo 'bgcolor="#F6F6F6"'; } else { echo
'bgcolor="#CCCCCC"'; } ?>
Feel free to comment - Happy Coding!
----
Manual Page -- http://www.php.net/manual/en/function.fmod.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+60353
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60353&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60353&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60353&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60353&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60353&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60353&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60353&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+60353&report=yes
Search -- http://master.php.net/manage/user-notes.php