묻고답하기
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
ASP 조회수나, 날짜 검색하는 방법 모르겠어요 ㅠㅠ
2004.05.23 16:08
ASP 조회수나, 날짜 검색하는 방법 모르겠어요 ㅠㅠ
아래에서 조회수가 readnum 이고 날짜가 writeday 인데 여기에는 wirteday를 안넣었습니다,
조회수 먼저 해볼려고 아직 ㅠㅠ
조회수를 검색할경우 아래같이 하면 만약 2를 넣으면 2만 검색되는데요..
2가 아니고 2이상인 경우를 검색가능하도록 하는 방법을 모르겠습니다..
답변 부탁드립니다 ㅠㅠ
<%
search = request("search")
str = request("str")
if search = "name" then
sql = "select * from board where name like '%" & str & "%' "
sql = sql & " ORDER BY board_idx DESC"
elseif search = "title" then
sql = "select * from board where title like '%" & str & "%' "
sql = sql & " ORDER BY board_idx DESC"
elseif search = "content" then
sql = "select * from board where content like '%" & str & "%' "
sql = sql & " ORDER BY board_idx DESC"
elseif search = "readnum" then
sql = "select * from board where readnum like '%" & str & "%' "
sql = sql & " ORDER BY board_idx DESC"
end if
sql = "select * from board where " & search & " like '%" & str & "%' "
sql = sql & " ORDER BY board_idx DESC"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql,"DSN=board;UID=;PWD=",3
%>
<HTML>
<HEAD>
<TITLE>검색결과</TITLE>
</HEAD>
<BODY>
<% if rs.BOF or rs.EOF then %>
<a href="list.asp">list로 돌아가기</a>
<%
else
rs.MoveLast
count = rs.recordcount
rs.MoveFirst
%>
<%= str%> (으)로 검색한 결과 <%= count%>
<table border="1" cellspacing="0" cellpadding="5">
<tr>
<td>번호</td>
<td>글쓴이</td>
<td>날짜</td>
<td>제목</td>
<td>조회수</td>
</tr>
<% Do until rs.EOF %>
<tr>
<td><%=rs("board_idx")%></td>
<td><%=rs("name")%></td>
<td><%=left(rs("writeday"),10)%></td>
<td><a href ="content.asp?borard_idx=<rs("board_idx")%>"><%=rs("title")%></a></td>
<td><%=rs("readnum")%></td>
</tr>
<%
rs.movenext
loop
%>
</table>
<p>
<a href="list.asp">list로 돌아가기</a>
<% end if%>
</body>
</html>
<%
rs.Close
Set rs = Nothing
%>
아래에서 조회수가 readnum 이고 날짜가 writeday 인데 여기에는 wirteday를 안넣었습니다,
조회수 먼저 해볼려고 아직 ㅠㅠ
조회수를 검색할경우 아래같이 하면 만약 2를 넣으면 2만 검색되는데요..
2가 아니고 2이상인 경우를 검색가능하도록 하는 방법을 모르겠습니다..
답변 부탁드립니다 ㅠㅠ
<%
search = request("search")
str = request("str")
if search = "name" then
sql = "select * from board where name like '%" & str & "%' "
sql = sql & " ORDER BY board_idx DESC"
elseif search = "title" then
sql = "select * from board where title like '%" & str & "%' "
sql = sql & " ORDER BY board_idx DESC"
elseif search = "content" then
sql = "select * from board where content like '%" & str & "%' "
sql = sql & " ORDER BY board_idx DESC"
elseif search = "readnum" then
sql = "select * from board where readnum like '%" & str & "%' "
sql = sql & " ORDER BY board_idx DESC"
end if
sql = "select * from board where " & search & " like '%" & str & "%' "
sql = sql & " ORDER BY board_idx DESC"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql,"DSN=board;UID=;PWD=",3
%>
<HTML>
<HEAD>
<TITLE>검색결과</TITLE>
</HEAD>
<BODY>
<% if rs.BOF or rs.EOF then %>
<a href="list.asp">list로 돌아가기</a>
<%
else
rs.MoveLast
count = rs.recordcount
rs.MoveFirst
%>
<%= str%> (으)로 검색한 결과 <%= count%>
<table border="1" cellspacing="0" cellpadding="5">
<tr>
<td>번호</td>
<td>글쓴이</td>
<td>날짜</td>
<td>제목</td>
<td>조회수</td>
</tr>
<% Do until rs.EOF %>
<tr>
<td><%=rs("board_idx")%></td>
<td><%=rs("name")%></td>
<td><%=left(rs("writeday"),10)%></td>
<td><a href ="content.asp?borard_idx=<rs("board_idx")%>"><%=rs("title")%></a></td>
<td><%=rs("readnum")%></td>
</tr>
<%
rs.movenext
loop
%>
</table>
<p>
<a href="list.asp">list로 돌아가기</a>
<% end if%>
</body>
</html>
<%
rs.Close
Set rs = Nothing
%>