Reputation: 963
I want to select all of the usernames. I tried to do SELECT username FROM members
and then mysql_fetch_array
. So I would do $data["username"]
. But I also want to select each row individually. Any help on how to do this would be helpful thank you.
Upvotes: 2
Views: 12221
Reputation: 263703
Use PDO for that.Example of using PDO
<?php
$stmt = $dbh->prepare("SELECT username FROM members");
if ($stmt->execute(array($_GET['username']))) {
while ($row = $stmt->fetch()) {
print_r($row);
}
}
?>
Upvotes: 4
Reputation: 24815
Loop through all results with while()
$result = mysql_query('SELECT username FROM members');
while ($username = mysql_fetch_assoc($result)){
echo $username['username']; //this will go for every result, so every row in the database
}
Upvotes: 1