-1
複数のデータ行を表示し、jsonデータを表示する必要があります。ここに私のコードは次のとおりです。複数のデータ行を表示し、jsonデータを表示する
<?php
$dinner_food_category=$_GET['DinnerFoodCategory'];
$conn = mysqli_connect("localhost","taig9_gen_user","GenAdmin1/Pass");
if($conn) {
$select_database = mysqli_select_db($conn,"taig9_genumy");
$select_query = "SELECT food_id,food_name,serving_type,serving_type_amount,singal_unit_weight FROM food_details WHERE category_id IN ('VEG00','VGB00','SUP00','CAK00')";
$result = mysqli_query($conn, $select_query);
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
$foods_id=$row['food_id'];
$foods_name=$row['food_name'];
$foods_type=$row['serving_type'];
$foods_type_amount=$row['serving_type_amount'];
$singal_unit_weights=$row['singal_unit_weight'];
}
$data = array("FoodId" => $foods_id,"FoodNames" => $foods_name,"FoodType" => $foods_type,"FoodAmount" => $foods_type_amount,"SingalUnitWeight"=> $singal_unit_weights);
}
echo stripslashes(json_encode($data));
}
?>
'$データ[] = array'と –
は質問の説明を追加し、適切なタグ – Shettyh
を言及while''でそれを置きます'$ data [] = $ row;'それはそれです。 –