prepare("SELECT * FROM users WHERE deleted = 'yes'"); while ($row = $q->fetch(PDO::FETCH_ASSOC)) { echo 'Flagging user records prior to ? for user ? as deleted - '; $stmt = $pdo->prepare("UPDATE users SET deleted = 'yes' WHERE uid = ? AND year < ?"); $stmt->execute([$row['year'],$row['uid'],$row['uid'],$row['year']]); echo $pdo->rowCount() . " rows affected.\n"; } } ?>