<%@ page contentType="text/html;charset=GBK" %>
<%@ page import="java.sql.*"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>查看留言</title>
</head>
<jsp:useBean id="db" scope="session" class="myBean.DBConnection" />
<body>
<p>
<%
	String keyword = request.getParameter("keyword");
	if(keyword==null)
		out.print("所有留言：");
	else
		out.print("查找结果：");
%>
<form action="list_msg2.jsp" method="post">
查找关键字：<input type="text" name="keyword" value="<%=keyword==null?"":keyword%>">
</form>
<table width="80%" border="1">
<%
	String sql = "select id, title from msg where pid=0";
	if(keyword!=null)
		sql += " and title='" +keyword+ "'";
		//sql += " and msg like '%" +keyword+ "%'";

	ResultSet rs = db.execQuery(sql);
	while(rs.next()) {
		String id= rs.getString("id");
%>
	<tr>
		<td width="80%"><a href="detail.jsp?id=<%=id%>"><%=rs.getString("title")%></a></td>
		<td><a href="msg.jsp?pid=<%=id%>">回复</a></td>
	</tr>
<%
	}
%>
</table>
<a href="msg.jsp?pid=0">新留言</a>
</body>

</html>