Im learning PHP by working on a personal project. Ive spend the last 2-hours trying to figure out why my IF statment is getting skipped inside my loop, Im a more experienced coder could provide me with a bit of help here, as I am currently at a stalemate.
What Im Trying To do
User makes picks for a round in sports tournament, when round is completed calculate the user standings based on number of correct picks.
Everything works as expected except Im having an (extremely) hard time calculating the number of correct picks.
IMAGE1: THE CODE SHOULD PUT OUT THE FOLLOWING

IMAGE2: THE CODE CURRENTLY PUTS OUT THE FOLLOWING (WRONG)
MY Code
$sql ="SELECT picks.*, results.*, users.*
FROM picks
inner join results on picks.gameID = results.gameID
inner join users on picks.userID = users.userID
WHERE picks.tournament = 'SixNations' AND picks.weekNum = '3'
order by users.lastname, users.firstname";
$stmnt = $db->prepare($sql);
//JUST DISABLING FOR DEBUGING PURPOSES
/*
$stmnt->bindValue(':tournament', $tournament);
$stmnt->bindValue(':weekNum', $round);*/
$stmnt->execute()
$picks = $stmnt->fetchAll();
$totalCorrectPicks = 0;
echo'<table class="table table-responsive table-striped">';
echo'<thead>';
echo'
<tr>
<th>FirstName</th>
<th>Picked Team</th>
<th>Winning Team</th>
<th>Margin</th>
<th>TOTAL CORRECT PICKS</th>
</tr>
</thead>
<tbody>';
$i = 1; //USED TO COUNT NR GAMES
foreach($picks as $pick){
$user = $pick['firstname'];
$picked = $pick['selectedTeam'];
$result = $pick['won'];
$nrGames = $i;
echo '<tr>';
echo'<td>';
echo $user;
echo'</td>';
echo'<td>';
echo $pick['selectedTeam'];
echo'</td>';
echo'<td>';
echo $pick['won'];
echo'</td>';
if($picked == $result){
//USER PICKED CORRECT TEAM
$totalCorrectPicks = $totalCorrectPicks +1;
echo'<td>';
$margin = abs($pick['pts'] - $pick['points']);
echo $margin;
echo'</td>';
}//if
else if($picked != $result){
//user PICKED INCORRECT TEAM
echo'<td>';
$totalCorrectPicks += 0;
$margin = '<span style="color:red">WRONG PICK</span>';
echo $margin;
echo'</td>';
}//else if
##THIS IF STATMENT IS GETTING IGNORED##
if($user != $pick['firstname']){
echo'<td>';
echo $output = 'Total Correct Picks'. $totalCorrectPicks.' / '.$i;
echo'</td>';
echo'</tr>';
}//if
$i++; //keep track of number games
}//foreach
echo'</tbody>';
echo'</table>';
As can be seen on image 2, and the code above the IF statement which should print the total correct games picked by each user is getting skipped / ignored. Any advise / help on why and / how I can fix this very welcome.

echo $output = 'Total Correct Picks'. $totalCorrectPicks.' / '.$i;Try just making itecho 'Total Correct Picks'. $totalCorrectPicks.' / '.$i;?$user = $pick['firstname'];, then you checkif($user != $pick['firstname']){- this will always be false, because they are always equal.