query($sql); $rowset = $result->fetchAll(PDO::FETCH_ASSOC); $errcode=$rowset[0]["ERRCODE"]; $data=array( "code"=>$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"]; $data["order_list"][]=$val; } } echo json_encode($data);