jsp中简单的查询方法!
文件名:select.jsp

<%@ page contentType="text/html;charset=GBK" %>
<%@include file=
"inc.jsp"%>
<Script language=
"JavaScript"]
//打开新窗口函数NewsWindow
function NewsWindow(id)
{
window.open('newswind.jsp?id='+id,'infoWin', 'height=400,width=600,scrollbars=yes,resizable=yes');
}
</Script>
<%
String search = request.getParameter(
"title");
sql=
"select * from new_sz where title like'%"+search+"%'" ;
//sql="select * from new_sz order by id desc ";
rs=apple.select(sql);
%>
<html>
<head>
<title>留言测试</title>
</head>
<body><center>
<form method=
"post" name="search" action="select.jsp" >
<input type=
"text" name="title"]
<input type=
"submit" name="submit" value="提交"]
<input type=
"reset" name="reset" value="重写"]
</form></center>

<table border=1 align='center' bgcolor=red width='80%'>
<tr>
<td>编号</td>
<td>主题</td>
<td>作者</td>
<td>时间</td>
<td>编辑</td>
<td>删除</td>
</tr>
<%
if(rs.next() )
{
%>
<tr>
<td><%=rs.getString(
"id")%></td>
<td>
<a href=
"javascript:NewsWindow(<%=rs.getInt("ID")%>)"]<u>
<%String title=rs.getString(
"title");
title=new String(title.getBytes(
"ISO-8859-1"),"GB2312" );
%><%=title%></u></td>
<td><%String author=rs.getString(
"author");
author=new String(author.getBytes(
"ISO-8859-1"),"GB2312" );
%><%=author%>
</td>
<td>
<%=rs.getString(
"Date")%>
</td>
<td>
<a href=newsedit2.jsp?id=<%=rs.getInt(
"ID")%>>编辑[/url]
</td>
<td>
<a href=delete.jsp?id=<%=rs.getInt(
"ID")%>>del[/url]
</td>
</tr>
<%
}
else {out.println(
"没有所查询内容");
}
apple.closeConn();
%>
<a href=show.jsp>fabiao[/url]
</table>

</body>
</html>
lunzi   2004-12-05 19:19:54 评论:0   阅读:2358   引用:0

发表评论>>

署名发表(评论可管理,不必输入下面的姓名)

姓名:

主题:

内容: 最少15个,最长1000个字符

验证码: (如不清楚,请刷新)

Copyright@2004-2010 powered by YuLog