ASP 高分 提问 搜索功能
<!--#include file="conn.asp"-->
<%
dim selectm,selectkey,selectid
selectkey=trim(request.form(trim("selectkey")))
selectm=trim(request.form("selectm"))
if selectkey="" then
selectkey=request.form("selectkey")
end if
if selectm="" then
selectm=request.form("selectm")
end if
set rs=server.CreateObject("adodb.recordset")
select case selectm
case "minc"
rs.open "select * from product where mingc like '%"&selectkey&"%' order by time desc",conn,1,1
case "class"
rs.open "select * from product where daclass like '%"&selectkey&"%' order by time desc",conn,1,1
case "time"
rs.open "select * from product where time like '%"&selectkey&"%' order by time desc",conn,1,1
end select
if rs.eof then
response.write "还没有产品!"
end if
dim j
if request("page")="" then
curpage=1
else
curpage=request("page")
end if
if not IsNumeric(curpage) then
response.Write("参数不对!")
response.end
end if
rs.pagesize=18 '******************设置每页显示文章数目***********************
dim totalput
totalPut=rs.recordcount
if curpage<1 then
curpage=1
end if
if (curpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
curpage= totalPut \ MaxPerPage
else
curpage= totalPut \ MaxPerPage + 1
end if
end if
rs.absolutepage=curpage
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="400" valign="top"><table width="0" height="20" border="0" cellpadding="0" cellspacing="0">
<%for j = 1 to rs.pagesize%>
<tr valign="middle">
<td width="20" valign="middle"><img src="admin/images/+.gif" width="15" height="15"></td>
<td height="23" valign="middle"><a href="showclass.asp?id=<%=rs("id")%>"><%=rs("mingc")%></a></td>
<td><span class="style1"> 类型:<%=rs("daclass")%></span></td>
<td><span class="style1">点击:<%=rs("dian")%></span></td>
<td><span class="style1">时间:<%=rs("time")%></span></td>
</tr>
<%
rs.movenext
if rs.eof then
j = j + 1
exit for
end if
next
%>
<%
end if
rs.close
set rs=nothing
%>
会出现 对象关闭时,不允许操作。 1.asp,行 23
帮忙看下
参考答案:if rs.eof then
response.write "还没有产品!"
end if
dim j
这个有问题
假如 没有值成空??
case "minc"
sql="select * from product where mingc like '%"&selectkey&"%' order by time desc"
case "class"
sql="select * from product where daclass like '%"&selectkey&"%' order by time desc"
case "time"
sql="select * from product where time like '%"&selectkey&"%' order by time desc"
好好看下