<!--#include virtual="/common/lib/dbcon.asp"-->
<!-- #Include virtual = "/common/lib/func.asp" -->
<%
bdm_idx = InputValue( request.querystring("bdm_idx") )

dim v_search, v_keyword, table, Query_Fields, Query_Where, Query_OrderBy
Dim recordcount
dim v_pagesize, v_totalpage, v_page, TotalCnt, v_block

Set ST = New SelectTable

table			= "bd_address_page"		'테이블
idx_field		= "adr_idx"			'기본키
oreder_filed	= "adr_name asc, adr_idx asc"	'정렬기준 필드
Query_Fields	= "adr_idx, bdm_idx, adr_m_id, adr_wdate, adr_name, adr_mobile1, adr_mobile2, adr_mobile3, adr_c_memo" '불러올 필드
v_pagesize		= 10				'목록개수
v_block			= 10				'페이지개수

'==================조합 쿼리문=======================
Query_Where = " where bdm_idx = '" & bdm_idx & "'"
andOrWhere	= " and "

Query_OrderBy = " ORDER BY "&oreder_filed
'==================조합 쿼리문=======================

'==================전체 레코드 수 뽑기===============
sql="select count(*) from " & table & Query_Where
set rs = DbCon.execute(sql)
recordcount=CInt( rs(0) ) '이 전체레코드갯수를 이용해서 페이지갯수를 뽑아 낼것이다.	
Set rs = nothing
'==================전체 레코드 수 뽑기===============

v_totalpage=fix((recordcount-1)/v_pagesize)+1 '전체덩어리갯수 
v_page = Request.QueryString("p_page")

if v_page="" then
	v_page = 1
elseif cint(v_page) < 1 then
	v_page = 1
elseif cint(v_page)>cint(v_totalpage) then
	v_page=cint(v_totalpage)
end if

'========================리스트 출력 쿼리문 생성======================
'MS-SQL
sql = "select Top " & v_pagesize& " " & Query_Fields & " from " & table
sql = sql & Query_Where & andOrWhere & " "&idx_field&" not in"
sql = sql & "(select top " & v_pagesize * (v_page - 1) & " "&idx_field&" from " & table
sql = sql & Query_Where & Query_OrderBy & ")"
sql = sql & Query_OrderBy
'========================리스트 출력 쿼리문 생성 끝======================
'response.write sql

list_data = ST.selectQueryTable( sql )
If isnull(list_data) Then
	TotalCnt = 0
Else
	TotalCnt = ubound( list_data ) + 1
End if

'글번호 num			= (TotalCnt - v_pagesize * (v_page - 1)) - i
%>
				<table class="table1" summary="주소록">
				<colgroup>
					<col width="30%" />
					<col width="30%" />
					<col width="*" />
				</colgroup>
				<thead>
					<tr>
						<th scope="col">이름</th>
						<th scope="col">연락처</th>
						<th scope="col">메모</th>
					</tr>
				</thead>
				<tbody>
<%
If TotalCnt = 0 Then
Else
	For i = 0 To ubound( list_data )
		ST.arr2Value( list_data(i) )
%>
					<tr>
						<td><%=adr_name%></td>
						<td><%=adr_mobile1%>-<%=adr_mobile2%>-<%=adr_mobile3%></td>
						<td><%=adr_c_memo%></td>
					</tr>
<%
	Next
End if
%>
				</tbody>
			</table>
			<div class="paginate">
				<%
				query_string = "?bdm_idx=" & server.urlencode( bdm_idx )
				url = "ajax_addr_memlist.asp" & query_string
				pageStyle2(url)
				%>
			</div>

<script type="text/javascript">
//<![CDATA[
$(function(){
	$("div.paginate a").click(function(){
		var url = $(this).attr("href");
		$("#detaillayer12 div.popct").load( url );
		return false;
	});
	clickArea(detaillayer12,0);
});
//]]>
</script>