PHP-每组显示一次类别

时间:2019-06-29 11:08:11

标签: php mysql sql

类别,而只显示一次类别标题。我有一个表保存类别标题(父级),第二个表保存子类别信息。尽管在显示信息时,我不知道如何只显示一次类别信息。

$result_array = mysqli_query($connect, "SELECT * 
                                        FROM tbl_customer, categories 
                                        WHERE tbl_customer.category_QA = categories.id 
                                        ORDER BY Category ASC");

while ($data = mysqli_fetch_array($result_array)) {
    echo $data["Category"];    //display once for every new category
    echo $data["productName"];
}

1 个答案:

答案 0 :(得分:2)

您可以检查更改

.
.
.
#attributes: array:5 [▼
    "id" => 1
    "title" => "First Project"
    "description" => "asdsdasdsadsadsadsadsa"
    "created_at" => null
    "updated_at" => null
  ]
.
.
.