Sql query returns only first row

前端 未结 2 536
南方客
南方客 2021-01-24 09:16

I\'m try to display a result of a select query, but i only get duplicate first row not all the rows. here is my code :

$query = \"SELECT Email from client\";
$r         


        
2条回答
  •  南笙
    南笙 (楼主)
    2021-01-24 10:19

    The fetch() function only fetches one record.

    Modify your code like this:

    $query = "SELECT Email from client";
    $res = $db->query($query);
    while($result = $res->fetch()){
        echo $result["Email"]."\n";
    }
    

提交回复
热议问题