PHP从同一列中选择多个项目以在页面中呈现

I guys I am having a bit of an issue with this

I have a select statement which looks like this belows

$stmt = $conn->prepare("SELECT * FROM Product WHERE id=:id");
    $stmt->bindParam('id',$id);
    $stmt->execute();
    $row = $stmt->fetch(PDO::FETCH_ASSOC);
    if($row) {];
        ?>  
<div>  <?echo $row['Name']; >? </div>
<div>  <?echo $row['Type']; >? </div>


$stmt1 = $conn->prepare("SELECT * FROM user WHERE Username IN ('john', 
                                'sarah', 'james')");
        $stmt1->bindParam('id',$id);
        $stmt1->execute();
        $row1 = $stmt1->fetch(PDO::FETCH_ASSOC);
        if($row1) {];
            ?>  
    <div>  <?echo $row1['username']; ?>' </div>

      <? } ?> //closing for the second select statement 

<? } ?>  //closing for the first select statement

The problem

The page render but where I have use SELECT * FROM user WHERE Username IN ('john', 'sarah', 'james') it is only showing one name instead of 3 names.

I know the select statement works because I try it in phpmyadmin and it does show all 3 names

Try this:

while($row1 = $stmt1->fetch(PDO::FETCH_ASSOC)) {
?>  
<div><?php echo $row1['username']; ?> </div>
<?php } ?>

Also remove $stmt1->bindParam('id',$id);

Because if($row1) only reads first row, you need to loop through the output by calling $stmt1->fetch(PDO::FETCH_ASSOC) each time for retrieving rows.

Try:

Instead of if($row1) use while($row1)

With if the loop only runs once but with while it runs as long there are results to loop through.