PHP how to beat the casino code!

Ok I am just starting to learn PHP and this is my first script.

It’s based on playing roulette, you wait for a string of the same color, and then bet on the other color hoping that it changes. If it doesn’t change you double your bet and you keep doubling it till you do win.

Thought I would stick the code here for other PHP newbies.

The script shows red and black tables indicating if red or black came up, and the results at the end. it is set to 1500 spins and to start betting when 8 in a row happens.



<head>
<title>gamble</title>
</head>
<body>
<?php
################################# CALL FUNCTION
$spins = 1500;                                ###
$bet_on = 8;                                ###
$bet_amount = 100;                            ###
tables( $spins, $bet_on, $bet_amount );        ###
################################# CALL FUNCTION

############################################################################################ START FUNCTION
function tables ( $spins, $bet_on, $bet_amount ) {

############################# VARIABLES
$red = '#FF0000';                    ###
$black = '#000000';                    ###            
$color = '0';                        ###
$set_color = '0';                    ###
$current_spin = '0';                ###
$this_color = '0';                    ###
$last_color = 'z';                    ###
$color_count = '0';                    ###
$last_bet = $bet_amount;            ###
$placed_bet = 'NO';                    ###
$current_winnings ='0';                ###
$current_losses ='0';                ###
$current_bet_amount ='0';            ###
$win = 'NO';                        ###
$loss = 'NO';                        ###
$highest_count = '0';                ###
$current_bet_amount = $bet_amount;    ###
$bet_already_made = 'NO';            ###
$wining_bet = '0';                    ###
$first_bet = 'YES';                    ###
$made_wining_bet = 0 ;                ###
$made_losing_bet = 0 ;                ###
############################# VARIABLES

################################################################## START WHOLE TABLE
echo "<table width=\"1000\" border=\"1\" align=\"center\"><tr>";

################################################################################################## START MAIN LOOP
for($i = 1 ; $i <= $spins ; $i++) {

####################### SETS THE POINT TO START A NEW ROW OF TABLES
if ($current_spin == 15){                                        ###
        $current_spin = 1;                                        ###
        echo"</tr><tr>";                                        ###        
}else{                                                            ###
        $current_spin = ($current_spin + 1);                    ###
}                                                                ###
####################### ENDS THE POINT TO START A NEW ROW OF TABLES

#################### GENERATE COLOR
$color = rand(0,1);                ###
if ($color == 0){                 ###
$set_color = $black;             ###
} else {                         ###
$set_color = $red;                 ###
}                                ###
#################### GENERATE COLOR

################################## COUNT COLORS
$this_color = $color;                        ###
                                            ###
if ($this_color != $last_color){             ###
        $color_count = 1;                    ###        
}else{                                        ###
        $color_count = ($color_count + 1 );    ###
}                                            ###
################################## COUNT COLORS

################################# HIGHEST COUNT
if ($color_count > $highest_count ){        ###
        $highest_count = $color_count;        ###
}                                            ###
################################# HIGHEST COUNT

################################# PLACE BET
if ($color_count >= $bet_on){            ###
            $placed_bet = 'YES';        ###
            $bet_already_made = 'YES';    ###            
}                                        ###
################################# PLACE BET

################################################################### WIN OR LOSE BET
if ($placed_bet == 'YES' || $bet_already_made == 'YES'){                        ###
                                                                                ###
        if ($this_color == $last_color){                                        ### 
                $loss = 'YES';                                                    ###                
                    if ($first_bet == 'YES'){                                    ###
                        $current_bet_amount = $bet_amount;                        ###
                        $first_bet = 'NO';                                        ###
                    }else{                                                        ###
                        $current_bet_amount = ($current_bet_amount * 2);        ###
                    }                                                            ###
                    $current_losses = ($current_losses - $current_bet_amount);    ###
                    $made_losing_bet ++ ;                                        ###
        } elseif ($this_color != $last_color){                                     ###    
                                                                                   ###
                $bet_already_made = 'NO';                                        ###
                $first_bet = 'YES';                                                ###
                $wining_bet = ($current_bet_amount * 2);                        ###
                $current_winnings = ($current_winnings + $wining_bet);            ###
                $win = 'YES';                                                    ###
                $color_count = 0;                                                ###
                $current_bet_amount = $bet_amount;                                ###
                $made_wining_bet ++ ;                                            ###
        }                                                                        ###
}                                                                                ###
################################################################### WIN OR LOSE BET

#########################################################################################################  START PRINT OUT CELL
if ($win == 'YES'){                                                                                                            ###
    echo"<td width=\"66\" height=\"33\" align=\"center\" bgcolor=\"$set_color\"><font color=\"#FFFFFF\" size=\"2\">
         <b>bet: \$$wining_bet <br>
         <font size=\"3\"><b>WIN</b></font>
         </font></td>";                                                                                                        ###
    }elseif ($loss == 'YES'){                                                                                                ###
         echo "<td width=\"66\" height=\"33\" align=\"center\" bgcolor=\"$set_color\"><font color=\"#FFFFFF\" size=\"2\">    
         bet: \$$current_bet_amount <br>
         <b>lost</b>
         </font></td>";                                                                                                        ###
    }else{                                                                                                                    ###
          echo "<td width=\"66\" height=\"33\" align=\"center\" bgcolor=\"$set_color\"><font color=\"#FFFFFF\" size=\"2\">
          </font></td>";                                                                                                    ###
}                                                                                                                            ###
############################################################################################################ END PRINT OUT CELL

############################# RESET
$win = 'NO';                    ###
$loss = 'NO';                    ###
$placed_bet = 'NO';                ###
$last_color = $this_color;        ###
$wining_bet = '0';                ###    
############################# RESET

}
################################################################################################## END MAIN LOOP

#################### END WHOLE TABLE
echo "</tr></table>";

########################################################################################## SHOW RESULTS
$total = ($current_winnings + $current_losses);                                                        ###
number_format ($total, 2);                                                                            ###
number_format ($current_winnings, 2);                                                                ###
number_format ($current_losses, 2);                                                                    ###
echo "<br><br>";                                                                                    ###
echo '<fieldset><legend> Your results are </legend>';                                                ###
echo "<center>";                                                                                    ###
echo "On <b>$spins<b> spins<br>";                                                                    ###
echo "<br>";                                                                                        ###
echo "You made <b>$made_losing_bet</b> losing bets losing <b>\$$current_losses</b> dollars.<br>";    ###
echo "You made <b>$made_wining_bet</b> wining bets wining <b>\$$current_winnings</b> dollars.<br>";    ###    
echo "<br>";                                                                                        ###
echo "The longest run was: $highest_count";                                                            ###
echo "<br><br>";                                                                                    ###
echo "<font color='#FF0000'><b>Your total winnings are: \$$total</b></font>";                        ###
echo "</center>";                                                                                    ###
echo '</fieldset>';                                                                                    ###
echo "<br><br>";                                                                                    ###
########################################################################################## SHOW RESULTS

############################################################################################ END FUNCTION
}
 ?>
</body>
</html>