<?php
header('content-type:application/json');
include($_SERVER['DOCUMENT_ROOT'] . "/API-Others/connection/conn.php");
$query = mysqli_query($conn, "SELECT *,COUNT(id) AS TOTAL FROM stocklist GROUP BY invoice_no ORDER BY category");
$stock_list = array();
while ($spec = mysqli_fetch_assoc($query)) {
    $invoiceno = $spec["invoice_no"];
    $stock_list[] =  $spec;

    // $query1 = mysqli_query($conn, "SELECT COUNT(id) AS TOTAL FROM stocklist WHERE invoice_no = '$invoiceno'");
    // while ($spec1 = mysqli_fetch_assoc($query1)) {
    //     $stock_list[] =  $spec1;
    // }
}

$resultData = array('code' => $statusCode, 'message' => $statusMessage, 'stock_list' => $stock_list);
echo json_encode($resultData);
