Mysqli只获取一行php [关闭]

I Know It's Question Asked so much time but i failed to find error in my code i'm using mysqli_fetch_array and code is below.

<?php
    include("../../config/db_config.php");
    $email_query = mysqli_query($con_db, "SELECT * FROM emailtemplate") or die("Erro");
    while( $row = mysqli_fetch_array($email_query)){
        echo $row["templatename"];
    }
?>

First mysqli_fetch_array() fetches all of the results and places them into an array of arrays. You could loop through that:

$rows = mysqli_fetch_array($email_query);
foreach($rows as $row) {
    echo $row["templatename"];
}

But what you likely want is the simpler mysqli_fetch_assoc() which fetches each row as an associative array:

$email_query = mysqli_query($con_db, "SELECT * FROM emailtemplate") or die("Erro");
while( $row = mysqli_fetch_assoc($email_query)){
    echo $row["templatename"];
}