script not returning correct results
Posted: Mon Oct 14, 2002 10:46 am
Hi,
I am working on a script to calculate returns on bets. This involves entering odds, stake etc. The problem I am having is with adding a new element into the calculation. In betting their is something called a Rule 4. This occurs in some races and diminsihes the retrun but there is no need to go into details.
Basically, here is how it works: There is a race with odds of 2/1 and a rule 4 of 20 cents is in place. With the betting rules this means that the odds must be multiplied by 1 - rule 4. In this case the rule 4 is .20 so 1 - .20 = .80 You now have to mulpiply the odds by .80 We only multiply the first number os in the case that is 2 (for a 5/1 bet it would be 5 etc)
.80 * 2 = 1.6 is the correct answer. This calculates ok in part of my script but when it gets to the second part on the same page it is returning 1.28 instead.
Here is the form code (from a function):
Here is the calculation and results code:
The foprm is called from another part of the page with
I have posted this on other forums but nobody seems to be able to help me. I am really stuck so any help is appreciated.
I have the entire script in a zip file if anyone wants to see it.
Regards,
Martin
I am working on a script to calculate returns on bets. This involves entering odds, stake etc. The problem I am having is with adding a new element into the calculation. In betting their is something called a Rule 4. This occurs in some races and diminsihes the retrun but there is no need to go into details.
Basically, here is how it works: There is a race with odds of 2/1 and a rule 4 of 20 cents is in place. With the betting rules this means that the odds must be multiplied by 1 - rule 4. In this case the rule 4 is .20 so 1 - .20 = .80 You now have to mulpiply the odds by .80 We only multiply the first number os in the case that is 2 (for a 5/1 bet it would be 5 etc)
.80 * 2 = 1.6 is the correct answer. This calculates ok in part of my script but when it gets to the second part on the same page it is returning 1.28 instead.
Here is the form code (from a function):
Code: Select all
function print_row($bet,$number)
{
echo "<table class=inputtable>\n<tr>\n<td align=left class=title>\n<b>$bet</b>\n</td>\n<td align=left
class=title>\n<b>Odds</b>\n</td>\n<td align=left class=deadheat>\n<b>D.H.<font
size=1>*</font></b>\n</td>\n</tr>";
for( $x = 1; $x < $number; $x++ ) {
echo "<tr>\n<td align=left class=oddstext>\nSelection
$x:</td>\n";
echo "<td align=left class=oddsform>";
echo "<INPUT TYPE=text class=input1 NAME=odds$x SIZE=4> / <INPUT TYPE=text class=input1 NAME=odds$x"."a
SIZE=2></td>";
echo "<td class=deadheatform>";
echo "<select name=deadheat$x>\n<option></option>\n<option
value=2>2</option>\n<option value=3>3</option>\n
<option
value=4>4</option>\n<option value=5>5</option>\n
<option value=6>6</option>\n</select>";
echo "</td>\n<td align=left class=oddsform>\n
<INPUT
TYPE=text class=input1 NAME=rf$x SIZE=4>";
echo "</tr>\n";
}
echo "<tr>\n<td align=left class=staketext>\nStake:</td>\n<td align=left class=stakeform>\n
<INPUT TYPE=text class=input1 NAME=stake SIZE=4>\n</td>\n</tr>\n";
echo "<tr>\n<td align=left colspan=2>\n<INPUT TYPE=submit NAME=submit VALUE=calculate>\n
<br>\n<font size=1>(* D.H. = Dead Heat)</font></td>\n</tr>\n</table>\n";
}Code: Select all
<?
if($calc == "Single")
{
if($rf1){$odds1 = $odds1 * (1 - $rf1);}
$total = ($odds1/$odds1a * $stake) + $stake;
if($deadheat1){$total = $total / $deadheat1;}
?>
<!-- results of your bet -->
<table align="left" class="resultstable">
<tr>
<td align="left" class="price">
<b>Price 1</b>
</td>
<td align="left" class="price2">
<?=$odds1."/".$odds1a?>
</td>
</tr>
<tr>
<td align="left" class="stake">
<b>Stake:</b>
</td>
<td class="stake2">
€<?=$stake?>
</td>
</tr>
<?
}Code: Select all
print_row(Single,1)I have the entire script in a zip file if anyone wants to see it.
Regards,
Martin