2021年3月5日星期五

Why its only some codes are being excuted in this my PHP function while looping

I have two table rows Where both results and Game1Select column are the same ,the problems is when running the function below it updates both status column as expected, but only update the balance once(in a second loop) .I tried to trim stuffs around but I come to realize it's ain't the cause since it works just fine the select query returns one row

  $sql = "SELECT single.*,users.balance,games.result,games.score,games.progress  FROM single  INNER JOIN users ON single.id = users.id  INNER JOIN games ON games.gameID = single.game1ID  WHERE (users.id = $_SESSION[id]) AND (result IS NOT NULL) AND (status = 'unchecked') AND (progress = 'FT');";     $cresult = mysqli_query($db,$sql);    if (!$cresult) { //do nothing.      }      else {       // if result found do below       $cresultCheck = mysqli_num_rows($cresult);       if ($cresultCheck > 0) {       while ($row = mysqli_fetch_assoc($cresult)) {          $betID = $row['betID'];        $Game1Name = $row['Game1Name'];        $Game1Select = trim($row['Game1Select']);        $Game1Odds = trim($row['Game1Odds']);        $Stake = $row['Stake'];        $Potential = $row['Potential'];        $Status = $row['Status'];        $date = $row['onDate'];        $result = trim($row['result']);          $balance = $row['balance'];        $newBalance = $Potential + $balance;             if (trim($Game1Select) == trim($result)) {             $updStatus = "UPDATE single           SET status = 'checked'           WHERE betID = $betID;";           $updStatusQuery = mysqli_query($db,$updStatus);             $updBalance = " UPDATE users           SET balance ='$newBalance'           WHERE id = '$_SESSION[id]';";           $updQuery = mysqli_query($db,$updBalance);                                       }           else {           //just check the stutus column as checked           $updStatus = "UPDATE single           SET status = 'checked'           WHERE betID = $betID;";           $updStatusQuery = mysqli_query($db,$updStatus);           }       }     }   }  
https://stackoverflow.com/questions/66501958/why-its-only-some-codes-are-being-excuted-in-this-my-php-function-while-looping March 06, 2021 at 11:03AM

没有评论:

发表评论