과정평가_정산기_기록/수강신청 도우미 사이트

(목록)과정평가형 정보처리산업기사 수강신청 도우미 사이트

값을변경 2022. 2. 13. 16:28

<!--     4시간에서 1:42:25 남김 -->

 

 

총 <%=count%>개의 교과목이 있습니다.

select count(name) count from course03;

 

테이블 쿼리 

select * from 
  (select idx, name lname from lecturer03)l, course03 c
where c.lecturer=l.idx
order by id

 

수정/삭제 

<td> 
	<a href="majorModify.jsp?id=<%=id %>">수정</a> / 
	<a href ="del.jsp?id=<%=id%>">삭제</a>
</td>

 

index.jsp 전체

더보기
<%@page import="course.dbcon"%>
<%@page import="java.sql.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
    <%
    	Connection con = null;
    	Statement stmt = null;
    	ResultSet rs = null;
    	
    	String count ="";
    	
    	String id ="";
    	String name ="";
    	String credit ="";
    	String lname ="";
    	String week ="";
    	String start_hour ="";
    	String end_hour ="";
    	
    	try{
    		con = dbcon.getConnection();
    		stmt = con.createStatement();
    		String sql = "select count(name) count from course03";
    		rs = stmt.executeQuery(sql);
    		rs.next();
    		count = rs.getString("count");
    		
    		stmt = con.createStatement();
    		sql="select * from "+
    			 "(select idx, name lname from lecturer03)l, course03 c "+
    			 "where c.lecturer=l.idx "+
    			 "order by id ";
    		rs = stmt.executeQuery(sql);
   
    %>
    
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>

<jsp:include page="header.jsp"></jsp:include>

<section>
	
	<h4>총 <%=count %>개의 교과목이 있습니다.</h4>
	
	<div class="table_div">
	
	<table>
		<tr>
			<th>과목코드</th>
			<th>과목명</th>
			<th>학점</th>
			<th>담당강사</th>
			<th>요일</th>
			<th>시작시간</th>
			<th>종료시간</th>
			<th>관리</th>
		</tr>
		<tr>
		<%
 		while(rs.next()){
			id =rs.getString("id");  
			name =rs.getString("name");  
			credit =rs.getString("credit");
			lname =rs.getString("lname"); 
			week =rs.getString("week");  
			start_hour = rs.getString("start_hour");
			end_hour = rs.getString("end_hour");
			
			switch(week){
			case "1" : week="월"; break;
			case "2" : week="화"; break;
			case "3" : week="수"; break;
			case "4" : week="목"; break;
			case "5" : week="금"; break;
			}

		%>
			<td><%=id %></td>
			<td><%=name %></td>
			<td><%=credit %></td>
			<td><%=lname %></td>
			<td><%=week %></td>
			<td><%=start_hour %></td>
			<td><%=end_hour %></td>
			<td> <a href="majorModify.jsp?id=<%=id %>">수정</a> / 
				<a href ="del.jsp?id=<%=id%>">삭제 </a></td>
		</tr>
		<%} %>
	</table>
		<button class="indexBtn" onclick="location.href='majorAdd.jsp'">작성</button>
	</div>
</section>
<%
    		if(rs!=null) rs.close();
    		if(stmt!=null) stmt.close();
    		if(con!=null) con.close();
    	}catch(Exception e){
    		e.printStackTrace();
    	}
%>

<jsp:include page="footer.jsp"></jsp:include>
</body>
</html>