I am creating an update proogram that takes the winner and loser of a game and adds their wins, loses, points for and points against to their profle in sql db. I have successfuly written the side for the winner, but when replicating tfor the loser, it iis returning an empty array from sql.
<?php
include("connection.php") ;
$winner= $_POST['win'];
$stmt1= $conn->prepare(' SELECT gamerid, wins, loses, pf, pa FROM fnl WHERE gamerid=? ');
$stmt1-> execute(array($winner)) ;
$rs=$stmt1->fetch(PDO::FETCH_ASSOC) ;
$win= $rs['wins'] + 1;
$pf=$rs['pf'] + $_POST['winpts'];
$pa=$rs['pf'] + $_POST['losspts'];
$stmt2=$conn-> prepare('UPDATE fnl SET wins= ?, pf= ?, pa= ? WHERE gamerid = ? ');
$stmt2 -> execute(array($win,$pf, $pa, $winner));
echo "update successsful";
?>
For the loser i have:
<?php
include("connection.php") ;
$loser= $_POST['loss'];
$stmt3= $conn->prepare(' SELECT gamerid, wins, loses, pf, pa FROM fnl WHERE gamerid=? ');
$stmt3-> execute(array($loser)) ;
$rs1=$stmt3->fetch(PDO::FETCH_ASSOC);
$rs1 is returning as an empty arrray and i have no idea why.. hopefully it is something simple that i am overlooking.
these are in the same .php file.
Any help greatly appreciated.