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