Page 200 - 3-2
P. 200

$result = mysqli_query($connect, $sql);
            //  반환된 전체 레코드 수 저장.
            $total_record = mysqli_num_rows($result);


            // check for empty result
            if (mysqli_num_rows($result) > 0) {
            // looping through all results
            //--------------------------------------------------------------
            // products node
            // success
            $response["status"] = "OK";
            $response["num_results"] = $total_record;
            $response["results"] = array();


            while ($row = mysqli_fetch_array($result)) {
            // temp user array
            $results = array();
            $results["c_l"] = $row["c_l"];
            $results["t_l"] = $row["t_l"];




            // 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);


                                                         - 200 -
   195   196   197   198   199   200   201   202   203   204   205