PHP returns 只有 table 的第一行

PHP returns only the first row from table

<?php
$connection = mysqli_connect("localhost","user","password");
if (!$connection) {
    die("Database connection failed: " . mysqli_error());
}
$db_select = mysqli_select_db($connection, "database");
if (!$db_select) {
    die("Database selection failed: " . mysqli_error());
}
$numeUser = mysqli_query($connection, "select * from table order by column_name");
$utilizator = mysqli_fetch_array($numeUser);
$numeUtilizator = $column_name[1];
$nume = $column_name[2];
$rol = $column_name[5];
$actiune = $column_name[8];

    $firstNames = $numeUtilizator;

    $lastNames = $nume;

    $productNames = $rol;

    $actions = $actiune;

    $data = array();
    $i=0;
    while($i < count($firstNames))
    {
      $row["firstname"] = $firstNames;
      $row["lastname"] = $lastNames;
      $row["productname"] = $productNames;
      $row["quantity"] = $actions;
      $data[$i] = $row;
      $i++;
    }

    header("Content-type: application/json"); 
    echo "{\"data\":" .json_encode($data). "}";
?>

我有上面的代码,但我不明白为什么它 returns 我只有数据库的第一行。它没有显示所有内容。有人问我错过了什么吗?

非常感谢。干杯!

部分原因是没有 javascript 但 php。

mysql_fetch_array(已弃用,不再存在于php 7)需要在while循环中调用,看文档,有你的问题,你只是获取第一排。

另一件事,代码很乱,搜索 google 模型视图控制器或模型视图展示器。

查询时切勿使用 SELECT *,仅 select 您将要使用的列。