Código
[{"product":"TEST_1","best_selling_product":"305"},{"product":"IPHONE 4S","best_selling_product":"108"}]
pero la notacion deberia ser
Código
[{"product":"TEST_1","best_selling_product":305},{"product":"IPHONE 4S","best_selling_product":108}]
Código
function best_selling_product(){ $sql = "SELECT product,SUM(sale_detail.amount) AS best_selling_product FROM sale_detail INNER JOIN product ON sale_detail.idproduct = product.idproduct GROUP BY sale_detail.idproduct ORDER BY SUM(sale_detail.amount) DESC LIMIT 0,5"; $result = $this->conexion->conexion->query($sql); while($record = $result->fetch_array(MYSQLI_ASSOC)){ $array[] = $record; } return $array; $this->conexion->cerrar(); }