ok
i have these codes below.
if($link!=$jtablegrid_link) { //this condition will limit the player from accidentally clicking the already taken number
if($user_click<50) {
//if user has tickets equal or greater than 1
if($balance_jackpot>=1 || $balance>=1) {
//check record existence first before writing.
$strQuery1 = "select count(*) as cnt from jtablegrid where box_no='".$link."'";
$res = mysql_query($strQuery1);
$row = mysql_fetch_array($res);
$intCount = $row['cnt'];
if($intCount == 0) {
$query = "INSERT INTO jtablegrid (username, box_no) VALUES ('$username','.$link.')";
mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error());
}
//this will subtract balance and balance_jackpot.
//everytime a user click it subtract 1 ticket from balance_jackpot column or from balance.
if($balance_jackpot>=1) {
$jackpot_subtracted = $balance_jackpot-1;
//then update user table.
$query = "UPDATE user SET balance_jackpot='$jackpot_subtracted' WHERE username='$username'";
mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error());
} elseif($balance>=1) {
#$balance_original = $balance;
#$balance = floor($balance); //round down.
if($balance>=1){
$balance_tmp = $balance-1;
//then update user table.
$query = "UPDATE user SET balance='$balance_tmp' WHERE username='$username'";
mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error());
}
}
} else {
echo "<br><br>";
echo "<b>Sorry, you don't have enough ticket.</b>";
echo "<br><br>";
}
} else {
echo "<br><br>";
echo "<b>You already reached the 50 click user limit per game.</b><br>";
echo "<b>Please wait for the next game, Thank you!</b>";
echo "<br><br>";
}
} elseif($link==$jtablegrid_link) {
echo "<br><br>";
echo "<b>That number is already taken.</b>";
echo "<br><br>";
}
what really bother me is when this if below is false
if($link!=$jtablegrid_link)
it still execute the other if inside it.
what do you think is a nice remedy for this?
or do you see bugs on my if elseif statements?
Thank you in advance.