Forum Moderators: coopster
Basically for every four $totalamount purchased a $freebonus is to be added.
if ($totalamount >= 4 and $totalamount < 8)
{
$freebonus = 1;
}
elseif ($totalamount >= 8 and $totalamount < 12)
{
$freebonus = 2;
}
elseif ($totalamount >= 12 and $totalamount < 16)
{
$freebonus = 3;
}
<?
// This is your input number... It wil be the one
// that changes via form input or whatever, for
// testing I just put 158 here to make sure the
// script works ok.
$totalamount = 158;
$count = 0;
$freebonus = 0;
while ($totalamount >= 0)
{
$bcount = 3;
while ($bcount >= 0)
{
if (($bcount == 0) and ($totalamount >= 1))
{
$freebonus = $freebonus + 1;
}
$bcount = $bcount - 1;
$totalamount = $totalamount - 1;
$count = $count + 1; //for testing purposes
}
}
echo "<br><br><H1>\$freebonus is $freebonus<br>";
?>
I tested it, and it adds 1 to $freebonus, for every 4 $totalamount. I think this is what you are asking for..?
-- Zak
<added> I found a minor problem and fixed it...
Heres the code you want:
$totalamount = 232; // just to give us a fun # to work with.
$fbonus = floor($totalamount / 4);
echo "<br><br><H1>\$fbonus is $fbonus<br>";
-- Zak