如题 不能实现按条件查询
<%@page contentType="text/html; charset=GBK"%>
<%@ page import="my1.Item"%>
<%@ page import="com.ht.pubpkg.ExecDb"%>
<%@ page import="java.sql.*"%><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>ItemDManage</title><script type="javascript">
function newwin(url) {
var newwin=window.open(url,"newwin","toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=yes,width=600,height=450");
newwin.focus();
return false;
}
</script></head>
<body><script type="javascript">
function submit11()
{
self.location.replace("ItemDManage.jsp")
}
</script><div align="center">
<font color="#6699FF" size="+3">项目管理日志</font>
</div>
<hr><%
int pageLine=3;
int totalRec=0;
int totalSub=0;
int intPage=1;if(request.getParameter("page")!=null)
intPage=Integer.parseInt(request.getParameter("page"));
else
intPage=1;String sql=null;
String sc=request.getParameter("SearchConditon");
String cc=request.getParameter("ConditionContent");if(cc!=null){
if(sc.equals("itemid")){
sql="select * from loginfo where itemid='"+cc+"'";
}
if(sc.equals("itemname")){
sql="select * from loginfo where itemname='"+cc+"'";
}
if(sc.equals("userid")){
sql="select * from loginfo where userid='"+cc+"'";
}
if(sc.equals("optiondate")){
sql="select * from loginfo where optiondate='"+cc+"'";
}
if(sc.equals("optioncontent")){
sql="select * from loginfo where optioncontent='"+cc+"'";
}
}else{
sql="select * from loginfo";
}ResultSet rs =null;
ExecDb mydb = new ExecDb();try{
rs = mydb.executeQuery(sql);
totalRec=mydb.getRecordCount(rs);
rs.close();
}
catch(Exception e){e.printStackTrace();}int intPageCount=0;
intPageCount=(totalRec+pageLine-1)/pageLine;if(intPage>intPageCount)
intPage=intPageCount;
%><table width="801" border="1" align="center" bgcolor="#FFFFFF" cellspacing="0">
<!--DWLayoutTable-->
<tr align="center" bgcolor="#0099FF">
<td width="120">项目代码</td>
<td width="120">项目名称</td>
<td width="120">操作用户</td>
<td width="120">操作时间</td>
<td width="120">操作内容</td>
</tr><%
int i=0;
String sItemID=new String();
String sItemName=new String();
String sUserid=new String();
String sOptiondate=new String();
String sOptioncontent=new String(); try{
rs = mydb.executeQuery(sql);
if(intPageCount>0){ for(i=1;i<=(intPage-1)*pageLine;i++)
rs.next(); for(i=1;i<=pageLine;i++)
{
if(rs.next()){
sItemID=rs.getString("itemid");
sItemName=rs.getString("itemname");
sUserid=rs.getString("userid");
sOptiondate=rs.getString("optiondate");
sOptioncontent=rs.getString("optioncontent");
%>
<tr>
<td width="120" align="center"><%=sItemID%></td>
<td width="120" align="center"><%=sItemName%></td>
<td width="120" align="center"><%=sUserid%></td>
<td width="120" align="center"><%=sOptiondate%></td>
<td width="120" align="center"><%=sOptioncontent%></td>
</tr>
<% }
}
rs.next();
}} catch(Exception e){e.printStackTrace();}
%><%
out.print("<TR>");
if(intPageCount*pageLine<totalRec)
intPageCount++;if(intPage>intPageCount)
intPage=intPageCount;if(intPage<1)
intPage=1;out.println("<form method=\"post\" name=fPageNum action=\"ItemDManage.jsp\">"); if(intPage<2)
out.println("<font color=\"whilte\">首页 上一页</font>");
else{
out.println("<a href=\"ItemDManage.jsp?page=1\">首页</a> ");
out.println("<a href=\"ItemDManage.jsp?page="+(intPage-1)+"\">上一页</a> "); } if((intPage-intPageCount)>=0)
out.println("<font color=\"whilte\">下一页 尾页</font>"); else {out.println("<a href=\"ItemDManage.jsp?page=" + (intPage+1) + "\">下一页</a> ");
out.println("<a href=\"ItemDManage.jsp?page=" + intPageCount + "\">尾页</a>");}
out.print(" 跳转到<input type=\"text\" name=\"page\" size=\"5\" maxlength=\"10\" value=\"" + intPage + "\">"); out.print("<input class=buttonface type=\"submit\" value=\"GO\" name=\"cndok\"></span></p></form>");
out.print("</td>");
out.print("</tr>");
%>
</table><font color="#6699FF" size="+2">查询条件:</font><font color="#6699FF" size="+2">
条件内容:</font><form name="form1" method="post" action="ItemDManage.jsp"><font size="2">
<input type="radio" checked name="SearchConditon" value="itemid">项目代码</font> <font size="2">
<input name="ConditionContent" type="text" size="20" maxlength="20"><br> <input type="radio" name="SearchConditon" value="itemname">项目名称<br>
<input type="radio" name="SearchConditon" value="userid">操作用户<br> <input type="radio" name="SearchConditon" value="optiondate">操作时间<br> <input type="radio" name="SearchConditon" value="optioncontent">操作内容</font> <font size="2">
<input type="submit" name="search" value="查询"></font><br>
</form></body></html>到底是为什么呢
<%@page contentType="text/html; charset=GBK"%>
<%@ page import="my1.Item"%>
<%@ page import="com.ht.pubpkg.ExecDb"%>
<%@ page import="java.sql.*"%><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>ItemDManage</title><script type="javascript">
function newwin(url) {
var newwin=window.open(url,"newwin","toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=yes,width=600,height=450");
newwin.focus();
return false;
}
</script></head>
<body><script type="javascript">
function submit11()
{
self.location.replace("ItemDManage.jsp")
}
</script><div align="center">
<font color="#6699FF" size="+3">项目管理日志</font>
</div>
<hr><%
int pageLine=3;
int totalRec=0;
int totalSub=0;
int intPage=1;if(request.getParameter("page")!=null)
intPage=Integer.parseInt(request.getParameter("page"));
else
intPage=1;String sql=null;
String sc=request.getParameter("SearchConditon");
String cc=request.getParameter("ConditionContent");if(cc!=null){
if(sc.equals("itemid")){
sql="select * from loginfo where itemid='"+cc+"'";
}
if(sc.equals("itemname")){
sql="select * from loginfo where itemname='"+cc+"'";
}
if(sc.equals("userid")){
sql="select * from loginfo where userid='"+cc+"'";
}
if(sc.equals("optiondate")){
sql="select * from loginfo where optiondate='"+cc+"'";
}
if(sc.equals("optioncontent")){
sql="select * from loginfo where optioncontent='"+cc+"'";
}
}else{
sql="select * from loginfo";
}ResultSet rs =null;
ExecDb mydb = new ExecDb();try{
rs = mydb.executeQuery(sql);
totalRec=mydb.getRecordCount(rs);
rs.close();
}
catch(Exception e){e.printStackTrace();}int intPageCount=0;
intPageCount=(totalRec+pageLine-1)/pageLine;if(intPage>intPageCount)
intPage=intPageCount;
%><table width="801" border="1" align="center" bgcolor="#FFFFFF" cellspacing="0">
<!--DWLayoutTable-->
<tr align="center" bgcolor="#0099FF">
<td width="120">项目代码</td>
<td width="120">项目名称</td>
<td width="120">操作用户</td>
<td width="120">操作时间</td>
<td width="120">操作内容</td>
</tr><%
int i=0;
String sItemID=new String();
String sItemName=new String();
String sUserid=new String();
String sOptiondate=new String();
String sOptioncontent=new String(); try{
rs = mydb.executeQuery(sql);
if(intPageCount>0){ for(i=1;i<=(intPage-1)*pageLine;i++)
rs.next(); for(i=1;i<=pageLine;i++)
{
if(rs.next()){
sItemID=rs.getString("itemid");
sItemName=rs.getString("itemname");
sUserid=rs.getString("userid");
sOptiondate=rs.getString("optiondate");
sOptioncontent=rs.getString("optioncontent");
%>
<tr>
<td width="120" align="center"><%=sItemID%></td>
<td width="120" align="center"><%=sItemName%></td>
<td width="120" align="center"><%=sUserid%></td>
<td width="120" align="center"><%=sOptiondate%></td>
<td width="120" align="center"><%=sOptioncontent%></td>
</tr>
<% }
}
rs.next();
}} catch(Exception e){e.printStackTrace();}
%><%
out.print("<TR>");
if(intPageCount*pageLine<totalRec)
intPageCount++;if(intPage>intPageCount)
intPage=intPageCount;if(intPage<1)
intPage=1;out.println("<form method=\"post\" name=fPageNum action=\"ItemDManage.jsp\">"); if(intPage<2)
out.println("<font color=\"whilte\">首页 上一页</font>");
else{
out.println("<a href=\"ItemDManage.jsp?page=1\">首页</a> ");
out.println("<a href=\"ItemDManage.jsp?page="+(intPage-1)+"\">上一页</a> "); } if((intPage-intPageCount)>=0)
out.println("<font color=\"whilte\">下一页 尾页</font>"); else {out.println("<a href=\"ItemDManage.jsp?page=" + (intPage+1) + "\">下一页</a> ");
out.println("<a href=\"ItemDManage.jsp?page=" + intPageCount + "\">尾页</a>");}
out.print(" 跳转到<input type=\"text\" name=\"page\" size=\"5\" maxlength=\"10\" value=\"" + intPage + "\">"); out.print("<input class=buttonface type=\"submit\" value=\"GO\" name=\"cndok\"></span></p></form>");
out.print("</td>");
out.print("</tr>");
%>
</table><font color="#6699FF" size="+2">查询条件:</font><font color="#6699FF" size="+2">
条件内容:</font><form name="form1" method="post" action="ItemDManage.jsp"><font size="2">
<input type="radio" checked name="SearchConditon" value="itemid">项目代码</font> <font size="2">
<input name="ConditionContent" type="text" size="20" maxlength="20"><br> <input type="radio" name="SearchConditon" value="itemname">项目名称<br>
<input type="radio" name="SearchConditon" value="userid">操作用户<br> <input type="radio" name="SearchConditon" value="optiondate">操作时间<br> <input type="radio" name="SearchConditon" value="optioncontent">操作内容</font> <font size="2">
<input type="submit" name="search" value="查询"></font><br>
</form></body></html>到底是为什么呢
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货