query($sql); $rowset = $result->fetchAll(PDO::FETCH_ASSOC); $errcode=$rowset[0]["ERRCODE"]; $data=array( "code"=>$rowset[0]["ERRCODE"], "info"=>$rowset[0]["ERRINFO"] ); if ($errcode ==0){ foreach ($rowset as $v){ $val=array(); $val["order_no"]=$v["MAIN_ID"]; $val["order_time"]=$v["ORDER_TIME"]; $val["order_status"]=$v["ORDER_STATUS"]; $val["prod_code"]=$v["PROD_CODE"]; $val["prod_name"]=$v["PROD_NAME"]; $val["price"]=$v["PRICE"]; $val["start_area"]=$v["START_AREA"]; $val["end_area"]=$v["END_AREA"]; $val["go_info"]=$v["GO_INFO"]; $val["back_info"]=$v["BACK_INFO"]; $val["direction"]=$v["DIRECTION"]; $val["run_days"]=$v["RUN_DAYS"]; $val["need_pay"]=$v["NEED_PAY"]; $val["pay_second"]=$v["PAY_SECOND"]; $val["if_bus"]=$v["IF_BUS"]; $val["if_hotel"]=$v["IF_HOTEL"]; $val["if_sightspot"]=$v["IF_SIGHTSPOT"]; $val["direction"]=$v["DIRECTION"]; $val["customer_name"]=$v["CUSTOMER_NAME"]; $val["customer_mobile"]=$v["CUSTOMER_MOBILE"]; $val["customer_id"]=$v["CUSTOMER_ID"]; $val["get_ticket"]=$v["GET_TICKET"]; $val["ticket_list"]=$v["TICKET_LIST"]; $data["order_list"][]=$val; } } echo json_encode($data);