bbs/list.jsp
페이지 정보
본문
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/include/header.jsp" %>
<%
String code = request.getParameter("code"); //데이타베이스 게시판 테이블명
//게시판 타이틀
String bbs_title = "";
if(code.equals("notice")){
bbs_title = "공지게시판";
}else if(code.equals("free")){
bbs_title = "자유게시판";
}else if(code.equals("gallery")){
bbs_title = "갤러리게시판";
}else if(code.equals("qna")){
bbs_title = "QnA게시판";
}
//총 게시물 수 (공지글 제외)
String sql_count="select count(*) from "+code+" where gongji != '1'";
Connection conn_count=DriverManager.getConnection(url, user, password);
Statement stmt_count=conn_count.createStatement();
ResultSet rs_count=stmt_count.executeQuery(sql_count);
int total_record = 0;
if(rs_count.next()){
total_record = rs_count.getInt(1);
}
rs_count.close();
stmt_count.close();
conn_count.close();
%>
<table width=100% height=50 border=0>
<tr>
<td align=center style="color:#777;font-size:14px;font-weight:bold;">[<%=bbs_title %>]</td>
</tr>
</table>
<center>
<table width="700" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>Total : <%=total_record %></td>
</tr>
</table>
<table width="700" border="0" cellpadding="0" cellspacing="0">
<tr bgcolor="#e5ecef" height="30">
<td width="60" align="center"><b>번호</b></td>
<td width="440"><b>제목</b></td>
<td width="100" align="center"><b>글쓴이</b></td>
<td width="100" align="center"><b>날짜</b></td>
</tr>
<%
// 공지글
String sql_top = "select * from "+code+" where gongji = '1' order by uid desc"; // 최신순 정렬
Connection conn_top=DriverManager.getConnection(url, user, password);
Statement stmt_top=conn_top.createStatement();
ResultSet rs_top=stmt_top.executeQuery(sql_top);
while(rs_top.next()){
String uid = rs_top.getString("uid");
String id = rs_top.getString("id");
String subject = rs_top.getString("subject");
String gongji = rs_top.getString("gongji");
String name = rs_top.getString("name");
String signdate = rs_top.getString("signdate");
String file1 = rs_top.getString("file1");
%>
<tr height="26" bgcolor="#fff6fa">
<td align="center"><font color=red>[공지]</font></td>
<td>
<a href="view.jsp?code=<%=code%>&uid=<%=uid%>"><%=subject %></a>
<%if(!file1.equals("")){ //파일첨부%> <img src="img/icon_file.gif"><%}%>
</td>
<td align="center"><%=name %></td>
<td align="center"><%=signdate %></td>
</tr>
<tr><td colspan=4 height=1 width=100% bgcolor=#d1dee2></td></tr>
<%
}
rs_top.close();
stmt_top.close();
conn_top.close();
// 일반,비밀글 목록
String sql=" select * from "+code+" where gongji != '1' order by uid desc"; // 최신순 정렬
Connection conn=DriverManager.getConnection(url, user, password);
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()){
String uid = rs.getString("uid");
String id = rs.getString("id");
String subject = rs.getString("subject");
String gongji = rs.getString("gongji");
String name = rs.getString("name");
String signdate = rs.getString("signdate");
String file1 = rs.getString("file1");
%>
<tr height="26">
<td align="center"><%=uid %></td>
<td>
<%if(gongji.equals("3")){ //비밀글 %>
<%if((session_level != null && session_level.equals("10")) || (session_id != null && session_id.equals(id))){ //관리자 or 작성자 %>
<a href="view.jsp?code=<%=code%>&uid=<%=uid%>"><%=subject%></a>
<%}else{ %>
<%=subject%>
<%} %>
<%}else{ //일반글 %>
<a href="view.jsp?code=<%=code%>&uid=<%=uid%>"><%=subject%></a>
<%} %>
<%if(!file1.equals("")){ //파일첨부%><img src="img/icon_file.gif"><%}%>
<%if(gongji.equals("3")){ //비밀글 %><img src="img/icon_secret.gif"><%} %>
</td>
<td align="center"><%=name %></td>
<td align="center"><%=signdate %></td>
</tr>
<tr><td colspan=4 height=1 width=100% bgcolor=#d1dee2></td></tr>
<%
}
rs.close();
stmt.close();
conn.close();
%>
<%if(total_record == 0){ //작성된 게시물이 없다면 %>
<tr><td colspan=4 align=center height=124>작성된 게시물이 없습니다.</td></tr>
<tr><td colspan=4 height=1 width=100% bgcolor=#d1dee2></td></tr>
<%} %>
</table>
<br>
<table width="700" border="0" cellpadding="0" cellspacing="0">
<tr>
<td></td>
<td align=right>
<%if(session_id != null){ //로그인 후 %>
<a href="write.jsp?code=<%=code%>">[글쓰기]</a>
<%}else{ %>
[로그인 후 작성하실 수 있습니다.]
<%} %>
</td>
</tr>
</table>
<br>
</center>
<%@ include file="/include/footer.jsp" %>
[실행화면]
- 이전글● ③ bbs 게시판 ( 옵션 : 공지,일반,비밀 - 처리 ) 23.03.15
- 다음글bbs/write.jsp 23.03.15
댓글목록
등록된 댓글이 없습니다.