query($sql); $rowset = $result->fetchAll(PDO::FETCH_ASSOC); $linker_count=$rowset[0]["LINKER_COUNT"]; $data=array( "code"=>$rowset[0]["ERRCODE"], "info"=>$rowset[0]["ERRINFO"] ); if ($linker_count >0){ foreach ($rowset as $v){ $val=array(); $val["customer_id"]=$v["ID"]; $val["customer_name"]=$v["CUSTOMER_NAME"]; $val["customer_mobile"]=$v["CUSTOMER_MOBILE"]; $val["customer_idtype"]=$v["CUSTOMER_ID_TYPE"]; $val["customer_idno"]=$v["CUSTOMER_ID_NO"]; $data["customer"][]=$val; } } echo json_encode($data);