Hi,
I need a function to do the following for a betting calculator I am putting together.
In the simplest form, I am calculating a "double" bet which is best explained like so:
we have 2 bets and 1 stake:
$total1 = $odds1 $stake + $stake;
$total = $total1 $odds2 + $total1;
What I need to do is add a form field for a user to say if a bet was a winner or not. (I have the form field already). If the bet is a winner it will be evaluated, if not it wont. The problem i am having is when calculating a multiple bet like the one above. How can I say
IF bet1 is a WINNER
...calculate $total1 using $stake
IF bet2 is a WINNER
...calculate using $total1 as $stake
(if the first bet isnt a winner, there will be no $total1 and the stake used should then be the original $stake.)
I am not too sure if I am explaining this correctly.
I think I am probably making a really innefficient use of code as well due to the amount of repeating elements but I didnt have time to work it all out with functions etc so I went for the messier approach.
This will be used for different bets so it would be better to have a function for this which will return the result
Regards,
Martin