I'm really bad with php loops like foreach and while, so I seek help.
I need to loop this code:
$loser = $pdo->prepare("SELECT `user` FROM `contest` WHERE `winner`= '0'");
$loser->execute();
$balance = $pdo->prepare("SELECT `balance` FROM `users` WHERE `login` = '$loser'");
$balance->execute();
$new_balance = $balance + 100;
$back = $pdo->prepare("UPDATE `users` SET `balance`= '$new_balance' WHERE `login`= '$loser'");
$back->execute();
$returned = $pdo->prepare("UPDATE `contest` SET `returned`= '1' WHERE `login`= '$loser'");
$returned->execute();
I tried a couple of things and looked for similar questions around here but I couldn't come up with the solution unfortunately. Can somebody help, please?