query($sql3); $result_array=$result->fetchAll(); $result->closeCursor(); $res_array = array(); $res_id_array = array(); foreach( $result_array as $res_info ) { $res_array[$res_info["RES_ID"]] = $res_info; $res_id_array[] = $res_info["RES_ID"]; } $sql4 = " SELECT * FROM base_resource_matrix WHERE RES_ID IN (".implode(",",$res_id_array).") AND cancel_flag = 0 "; $result=$pdo->query($sql4); $result_array=$result->fetchAll(); $result->closeCursor(); $bus_array = array(); $bus_max_line = array(); foreach( $result_array as $seat_info ) { if( !isset($bus_max_line[$seat_info["RES_ID"]]) ) { $bus_max_line[$seat_info["RES_ID"]] = 0; } if( !isset($bus_array[$seat_info["RES_ID"]]) ) { $bus_array[$seat_info["RES_ID"]] = array(); } if( !isset($bus_array[$seat_info["RES_ID"]][$seat_info["POS_Y"]]) ) { $bus_array[$seat_info["RES_ID"]][$seat_info["POS_Y"]] = array(); } $bus_array[$seat_info["RES_ID"]][$seat_info["POS_Y"]][$seat_info["POS_X"]] = $seat_info; $bus_max_line[$seat_info["RES_ID"]] = $bus_max_line[$seat_info["RES_ID"]] < $seat_info["POS_X"] ? $seat_info["POS_X"] : $bus_max_line[$seat_info["RES_ID"]]; } foreach( $bus_array as $res_id => $bus_info ) { $bus_info = $bus_array[$res_id]; echo "
RES_ID:{$res_id} => {$res_array[$res_id]["RES_NAME"]}
"; echo "
"; foreach( $bus_info as $pos_y => $seat_line ) { echo ""; $max_line_seat = $bus_max_line[$res_id]; for( $index_temp = 1;$index_temp <= $max_line_seat; $index_temp++ ) { $seat_info = isset($seat_line[$index_temp]) ? $seat_line[$index_temp] : array("POS_NAME" => "  "); echo ""; } echo ""; } echo "
".$seat_info["POS_NAME"]."
"; echo "
"; } exit();