if (mysql_num_rows($result) > 0) {
$result = mysql_fetch_array($result);
$product = array();
$product["name"] = $result["name"];
$product["unit"] = $result["unit"];
$product["calory"] = $result["calory"];
$product["carbohydrate"] = $result["carbohydrate"];
$product["category"] = $result["category"];
// success
$response["success"] = 1;
// user node
$response["product"] = array();
array_push($response["product"], $product);
// echoing JSON response
echo json_encode($response);
}
zastąp to przez
while(mysql_num_rows($result) > 0 && ($result = mysql_fetch_array($result))) {
$product = array();
$product["name"] = $result["name"];
$product["unit"] = $result["unit"];
$product["calory"] = $result["calory"];
$product["carbohydrate"] = $result["carbohydrate"];
$product["category"] = $result["category"];
// success
$response["success"] = 1;
// user node
$response["product"] = array();
array_push($response["product"], $product);
// echoing JSON response
echo json_encode($response);
}
wynikiem jest tablica i nie przechodzisz przez nią w pętli, więc daje tylko jeden element w tablicy