DB
-- 상품 테이블 create table prodt( number int identity(1,1) primary key, -- 고유번호 prodcode nvarchar(100) not null , -- 제품코드 prodname nvarchar(100) not null, -- 제품이름 prodinfo1 nvarchar(3000) null, -- 상세설명1 prodinfo2 nvarchar(3000) null, -- 상세설명2 prodpic nvarchar(100) null, -- 이미지 경로 sortcode nvarchar(100) null , -- 분류코드 stwon int not null, -- 정규가격 won int not null, -- 할인가격 proddate datetime default GETDATE(), -- 등록일 stcount int, -- 총수량 realcount int, -- 실수량 nowcount int -- 현재수량 ); -- 제품 분류 테이블 create table sortt ( number int identity(1,1) primary key , -- 고유번호 sortcode nvarchar(100) , -- 분류코드 sortname nvarchar(100), -- 분류명 sortdate nvarchar(50), -- 날짜 );
prodlist.asp
<!--#include virtual=./asp-shoppingMall/mall/include/header.asp -->
</header>
<body>
<!--#include virtual="./asp-shoppingMall/mall/include/header_menu.asp" -->
<!--#include file="dbcon.asp" -->
<%
' Dim totalCount
' sqlTotalCount =" select count(*) as totalcount from prodt"
' Set rsTotalCount=db.execute(sqlTotalCount)
' totalCount=rsTotalCount("totalcount")
Dim keyfield, key, page, startpage, ipp, ten, curPage, totalCount, totpage
keyfield=request("keyfield")
key=request("key")
if Request("page") ="" Then
curPage=1
Else
curPage=CInt(Request("page"))
end if
if Request("startpage")="" Then
startpage=1
Else
startpage=cint(Request("startpage"))
end if
ipp=10 '페이지마다 출력할 레코드의 개수를 나타낸다.
ten=10 '출력할 페이지의 개수를 나타낸다.
if key="" then
sql ="select count(*) as totalCount from prodt"
else
sql ="select count(*) as totalCount from prodt where "&keyfield &" like '%"& key &"%'"
end if
'Response.write sql
Set rs =db.Execute(sql)
totalCount=rs("totalCount")
%>
<div class="rows">
<div class="container">
<div class="col-xs-12 col-sm-12">
<div class="col-xs-2 col-sm-2"></div>
<div class="col-xs-8 col-sm-8">
<div>
<form action="prodlist.asp" method="post">
<div class="col-xs-12 col-sm-12">
<div class="col-xs-3 col-sm-3">
레코드 총수 : 총 <%= totalCount %>개
</div>
<div class="col-xs-3 col-sm-3">
<select class="form-control" name="keyfield">
<option value="prodname" <% if keyfield="prodname" then %>selected <% end if %> >제품명</option>
<option value="prodcode" <% if keyfield="prodcode" then %>selected <% end if %> >제품코드</option>
<option value="sortcode" <% if keyfield="sortcode" then %>selected <% end if %> >분류코드</option>
</select>
</div>
<div class="col-xs-3 col-sm-3">
<input type="text" class="form-control" name ="key" value="<%= key %>"/>
</div>
<div class="col-xs-3 col-sm-3">
<input type="submit" value="검색" class="btn" />
</div>
</div>
</form>
<br/></br/><br/></br/>
</div>
<div class="row placeholders">
<!--
number int identity(1,1) primary key, -- 고유번호
prodcode nvarchar(100) not null , -- 제품코드
prodname nvarchar(100) not null, -- 제품이름
prodinfo1 nvarchar(3000) null, -- 상세설명1
prodinfo2 nvarchar(3000) null, -- 상세설명2
prodpic nvarchar(100) null, -- 이미지 경로
sortcode nvarchar(100) null , -- 분류코드
stwon int not null, -- 정규가격
won int not null, -- 할인가격
proddate datetime default GETDATE(), -- 등록일
stcount int, -- 총수량
realcount int, -- 실수량
nowcount int -- 현재수량
-->
<%
' 내림차순 오름차순이 반대이다 . asc, desc
Set DbRec=Server.CreateObject("ADODB.Recordset")
DbRec.CursorType=1
if key="" Then
DbRec.Open "select * from prodt order by number asc ", db
else
DbRec.Open "select * from prodt where " & keyfield & " like '%"&key &"%' order by number asc", db
end if
%>
<%
if DbRec.EOF then 'DbRec 가 없다면 그냥 넘어가기 한다.
else ' 검색된 결과갑이 있다면 레코드의 수를 계산하고 각 페이지 값을 계산한다.
DbRec.MoveLast
postcount =DbRec.Recordcount
totpage =int(postcount/ipp)
totpage=cint(totpage)
if (totpage * ipp) <> postcount then totpage=totpage+1
For a=1 to (curpage-1) * ipp
DbRec.MovePrevious
Next
%>
<%
For i=1 to ipp
if totpage= curpage then
value =postcount Mod ipp
if i > value and value <> 0 then
Exit For
end if
end if
%>
<div class="col-xs-12 col-sm-6 placeholder" style="margin-top:30px;">
<div class="col-xs-6 col-sm-6">
<img data-src="holder.js/200x200/auto/sky" class="img-responsive" alt="200x200" src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/PjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIgdmlld0JveD0iMCAwIDIwMCAyMDAiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPjxkZWZzLz48cmVjdCB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIgZmlsbD0iIzBEOEZEQiIvPjxnPjx0ZXh0IHg9Ijc0LjA1NDY4NzUiIHk9IjEwMCIgc3R5bGU9ImZpbGw6I0ZGRkZGRjtmb250LXdlaWdodDpib2xkO2ZvbnQtZmFtaWx5OkFyaWFsLCBIZWx2ZXRpY2EsIE9wZW4gU2Fucywgc2Fucy1zZXJpZiwgbW9ub3NwYWNlO2ZvbnQtc2l6ZToxMHB0O2RvbWluYW50LWJhc2VsaW5lOmNlbnRyYWwiPjIwMHgyMDA8L3RleHQ+PC9nPjwvc3ZnPg==" data-holder-rendered="true">
</div>
<div class="col-xs-6 col-sm-6">
<p>
번호 : <%= DbRec("number") %>
</p>
<p><b>분류명:</b> <%= DbRec("sortcode") %> </p>
<p><b>정규가격:</b> <%= FormatNumber(DbRec("stwon"), 0, -1)%> 원</p>
<p><b>재고수량:</b> <%=FormatNumber(DbRec("nowcount"), 0, -1) %>개</p>
</div>
<div class="col-xs-12">
<h4> <p><b>제품명:</b> <%=DbRec("prodname") %>(<%= DbRec("prodcode")%>)</p></h4>
<span class="text-muted" ><p><b>할인가격:</b>
<%= FormatNumber(DbRec("won"),0 ,-1) %>원
(할인률 : <%= CInt(((DbRec("won")/DbRec("stwon"))*100) )%>%)</p>
</span>
</div>
</div>
<%
DbRec.MovePrevious
NEXT
end if
%>
</div> <!-- End row placeholders -->
</div> <!-- RS 및 페이지네이션 끝 -->
</div>
</div>
</div>
<div class="text-center">
<nav aria-label="Page navigation">
<ul class="pagination">
<% if totpage < ten then %>
<% if startpage=1 then %>
<li class="page-item">
<a class="page-link" href="prodlist.asp?page=1&startpage=<%=startpage%>&keyfield=<%= keyfield%>&key=<%=key%>" aria-label="Previous">
<span aria-hidden="true">처음</span>
<span class="sr-only">첫페이지</span>
</a>
</li>
<% else %>
<li class="page-item">
<a class="page-link" href="prodlist.asp?page=<%=cint(Request("page"))-1 %>&startpage=<%=cint(Request("page") )-ten%>&keyfield=<%= keyfield%>&key=<%=key%>" aria-label="Previous">
<span aria-hidden="true">«</span>
<span class="sr-only">이전</span>
</a>
</li>
<% end if %>
<%
For a=startpage to startpage+ten-1
if a>totpage then
exit for
else
if a=curpage then
Response.Write "<li class='active' ><a class='page-link' href='#'>" &a&"</a></li>"
else
%>
<li class='page-item' ><a href='prodlist.asp?page=<%= a %>&startpage=<%=startpage %>&keyfield=<%= keyfield %>&key=<%=key%>' class='page-link'><%=a%></a></li>
<%
end if
end if
Next
if((startpage\ten)=(totpage\ten)) Then
%>
<li class="page-item">
<a class="page-link" href="prodlist.asp?page=<%= totpage %>&startpage=<%=startpage %>&keyfield=<%= keyfield %>&key=<%=key%>" aria-label="Next">
<span aria-hidden="true">끝</span>
<span class="sr-only">Next</span>
</a>
</li>
<%
else
%>
<li class="page-item">
<a class="page-link" href="prodlist.asp?page=<%= a %>&startpage=<%= a%>&keyfield=<%= keyfield%>&key=<%=key%>" aria-label="Next">
<span aria-hidden="true">»</span>
<span class="sr-only">Next</span>
</a>
</li>
<%
end if
Else
'' Response.write "탑 else"
For a=startpage to totpage
if a=curpage Then
Response.write "<li class='active'>"
Response.Write "<a class='page-link' href='prodlist.asp' >"&a&"</a>"
Response.Write "</li>"
end if
'Response.Write "라"
next
%>
<% end if %>
</ul>
</nav>
</div>
<!--
<nav aria-label="Page navigation example">
<ul class="pagination">
<li class="page-item">
<a class="page-link" href="#" aria-label="Previous">
<span aria-hidden="true">«</span>
<span class="sr-only">Previous</span>
</a>
</li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item"><a class="page-link" href="#">2</a></li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item">
<a class="page-link" href="#" aria-label="Next">
<span aria-hidden="true">»</span>
<span class="sr-only">Next</span>
</a>
</li>
</ul>
</nav> -->
<div style="margin-bottom:200px;">
</div>
<!--#include virtual=./asp-shoppingMall/mall/include/footer.asp -->
header.asp
<%@Language="VBScript" CODEPAGE="65001" %>
<%
' 한글깨짐 방지 처리
Response.CharSet="utf-8"
Session.codepage="65001"
Response.codepage="65001"
Response.ContentType="text/html;charset=utf-8"
%>
<% response.buffer=true %>
<!-- Buffer 프로퍼티를 이용한 페이지 버퍼링하기
Response.Buffer 프로퍼티를 사용하면 페이지를 버퍼링할 수 있다. 버퍼링이란 생성한 페이지를 바로
클라이언트로 전달하는 것이 아니라 서버에 보관한 다음 명령에 따라 보내거나 보내지 않게 하는 것이다.
버퍼링을 통해서 클라이언트에 보낼 페이지를 제어할 수 있다.
Response.Buffer = True 혹은 False
True 로 지정하면 페이지 내용을 바로 보내지 않고 버퍼링을 한다. 이 내용은 HTML 페이지 상단에 명시한다.
이 버퍼링된 페이지를 제어하기 위해서는 Flush, Clear , End 메소드를 사용한다. 버퍼링된 페이지는 End 나
Flush 메소드의 명령을 받기 전까지는 페이지를 버퍼에 그대로 가지고 있다.
Response.Flush : Buffer 에 있는 결과를 즉시 보낸다. Response.Write 메소드를 사용한
출력 내용도 처리가 가능하다.
Respose.Clear : Buffer 에 있는 모든 HTML 결과를 지운다.
Response.End : ASP 파일 처리를 멈추고 현재 결과값을 보낸다. -->
<html lang="ko">
<head>
<title>macaronics</title>
<meta http-equiv="content-type" content="text/html"; charset="utf-8" >
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 위 3개의 메타 태그는 *반드시* head 태그의 처음에 와야합니다; 어떤 다른 콘텐츠들은 반드시 이 태그들 *다음에* 와야 합니다 -->
<title>macaronics</title>
<!-- 부트스트랩 -->
<!-- 합쳐지고 최소화된 최신 CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<!-- 부가적인 테마 -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">
<!-- 합쳐지고 최소화된 최신 자바스크립트 -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<!-- IE8 에서 HTML5 요소와 미디어 쿼리를 위한 HTML5 shim 와 Respond.js -->
<!-- WARNING: Respond.js 는 당신이 file:// 을 통해 페이지를 볼 때는 동작하지 않습니다. -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<!-- <style>
#header_menu, #navbar, .navbar navbar-inverse navbar-static-top{
background:#EE7785;
color: white;
}
#header_menu .navbar-header{
color: white;
}
.navbar-inverse .navbar-brand{
background:#EE7785;
}
.navbar-inverse .navbar-nav>li>a{
color:white;
}
.navbar-inverse .navbar-nav>.active>a, .navbar-inverse .navbar-nav>.open>a{
background:#337AB7;
}
#navbar .navbar-nav>li>a:hover, #navbar .navbar-nav>li>a:hover{
background:#337AB7;
}
#footer {
position:fixed;
left:0px;
bottom:0px;
height:60px;
width:100%;
background:#EE7785;
color: white;
}
#footer p {
text-align: center;
vertical-align: middle;
}
</style> -->
header_menu.asp
<div class="navbar-wrapper">
<div class="container">
<nav class="navbar navbar-inverse navbar-static-top">
<div class="container" id="header_menu">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Macaronics</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="/asp-shoppingMall/mall/">ASP mall</a></li>
<li class="active"><a href="/asp-shoppingMall/mall/adduser.asp">회원 등록</a></li>
<li><a href="/asp-shoppingMall/mall/prodlist.asp">상품목록</a></li>
<%
if session("id1") ="" then
%>
<li><a href="/asp-shoppingMall/mall/login.asp">로그인</a></li>
<%
else
%>
<li><a href="/asp-shoppingMall/mall/memberList.asp">회원록록</a></li>
<li><a href="/asp-shoppingMall/mall/logout.asp">로그아웃</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><%= session("id1") %>님 환영합니다.
<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="/asp-shoppingMall/mall/regedit.asp">회원정보 수정</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li class="dropdown-header">Nav header</li>
<li><a href="#">Separated link</a></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
<%
end if
%>
</ul>
</div>
</div>
</nav>
</div>
</div>
dbcon.asp
<%
Dim dbConnect, db '변수 선언'
' DB 연결 접속 정보 변수 저장
dbConnect = "Provider=SQLOLEDB; Data Source=CJH-PC;Initial Catalog=braverokmc; User id=braverokmc;password=1111"
' 연결 객체 생성
Set db = server.createObject("ADODB.Connection")
' 데이터베이스 접속
db.open dbConnect
%>
footer.asp
<p class="margin-top:500px"></p>
<div class="rows">
<div class="col-xs-3 col-sm-3" ></div>
<div class="col-xs-6 col-sm-6">
<!-- FOOTER -->
<footer id="footer">
<p> </p>
<p>© 2018 macaronics - Junho Choi</p>
<p> </p>
</footer>
</div><!-- /.container -->
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="http://bootstrapk.com/dist/js/bootstrap.min.js"></script>
</body>
</html>
제작 소스 - Junho choi - macaronics : https://github.com/braverokmc79/asp-shoppingMall













댓글 ( 4)
댓글 남기기