Im not trying to use a loop. I just one one value from one column from one row. I got what I want with the following code but there has to be an easier way using PDO.
You can use fetchColumn():
fetchColumn()
$q= $conn->prepare("SELECT name FROM `login_users` WHERE username=?"); $q->execute([$userid]); $username = $q->fetchColumn();