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>
<%@ 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
阅读:1746
引用:0
