Forums

PHP

This topic is locked

Calculation in PHP - Help an idiot :-)

Posted 11 Sep 2001 22:58:46
1
has voted
11 Sep 2001 22:58:46 Stephen Bateman posted:
I need to devide a total number of records in a record set by 2 then make sure the number is even and save it to a variable.

If anyone can help me out it would be appreciated

Replies

Replied 12 Sep 2001 01:54:08
12 Sep 2001 01:54:08 Tim Green replied:
Here's a little example that will put you on the right track :-

<?php
$totRecs=12;
if ($totRecs % 2) {
$theSaved = $totRecs/2;
echo "Number was even";
} else {
echo "Number not even";
}
?>

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>

Reply to this topic