-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'과에 넣어'while' –
추가 질문 설명과 적절한 태그 – Shettyh
을 언급 'while data '= array();'while'while'while''$ data [] = $ row;'그게 전부입니다. –