mercredi 1 juillet 2015

Iterate through specific rows sql php

I have a table that looks like this

+-----------+--------+----------------+---------------------+-------------------+                
| commentid | blogid | comment_author | comment_date        | blog_comment      |                
+-----------+--------+----------------+---------------------+-------------------+                
|         2 |      5 | random guy     | 2015-07-01 16:48:35 |                
|         3 |      5 | James          | 2015-07-01 18:54:03 |                 
+-----------+--------+----------------+---------------------+-------------------+   

inside there are 2 rows with the blogid=5

when run this code

$checkcomments = "SELECT * from blog_comments where blogid=5";

if ($result=$db->query($checkcomments)) {
while ($data=$result->fetch_object()) {         
    echo $data->comment_author;

It shows me only 1 name "Random" guy

How do I iterate through all author_names that are part of blogid=5?

Aucun commentaire:

Enregistrer un commentaire