Page 912 - 3-2
P. 912
$results["temp"] = $row["temp"];
// push single product into final response array
array_push($response["results"], $results);
}
// echoing JSON response
echo json_encode($response);
}
// else {
// no products found
// $response["success"] = 0;
// $response["message"] = "No products found";
// echo no users JSON
// echo json_encode($response);
// }
/*
// JSONArray 형식으로 만들기 위해서...
echo "{\"status\":\"OK\",\"num_results\":\"$total_record\",\"results\":[";
// 반환된 각 레코드별로 JSONArray 형식으로 만들기.
for ($i=0; $i < $total_record; $i++)
{
// 가져올 레코드로 위치 포인터 이동( )
mysqli_data_seek($result, $i);
$row = mysqli_fetch_array($result);
echo "{\"detector\":$row[detector],\"addr\":\"$row[addr]\",
\"room\":\"$row[room]\",\"fire\":\"$row[fire]\",
\"spark\":\"$row[spark]\",\"gas\":\"$row[gas]\",
\"temp\":\"$row[temp]\"}";
// 마지막 레코드 이전엔 를 붙인다 그래야 데이터 구분이 되니깐, . .
if($i<$total_record-1){
echo ",";
}
}
// JSONArray 의 마지막 닫기
echo "]}";
*/
mysqli_close($connect);
?>
- 912 -