谁能为一个刚接触ASP的新手完成站内搜索结果分页处理,感谢!
代码如下:
<!--#include file="utf-8.asp"-->
<!--#include file="conn.asp" -->
<!--#include file="config.asp" -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><%=request("key")%> </title>
<meta name="description" content="<%=config("description")%>" />
<meta name="keywords" content="<%=config("keywords")%>" />
<link href="images/style.css" type="text/css" rel="stylesheet" />
</head>
<body bgcolor="<%=config("bg")%>">
<!--#include file="header.asp" -->
<div align="center"><img src="/images/logo.jpg" width="100" height="80" alt="哪位高手能为一个刚接触ASP的新手完成站内搜索结果分页处理,感谢"title")%>" title="<%=config("title")%>" /></div>
<tr>
<td height="20">
<div style="border-bottom:#005AB5 15px solid;"></div></td>
</tr>
<!--#include file="search_so.asp" -->
<%
t=Trim(Request.Form("t"))
key=Trim(Request.Form("key"))
if t="" or key="" then
Response.Write("<script>alert('请输入关键词!');history.back();</script>")
Response.End()
end if
if t=1 then
sql="select * from [shop] where 1=0"
else
sql="select * from [news] where 1=0"
end if
keyArr=split(key," ")
for i=0 to ubound(keyArr)
sql=sql&" or title like '%"&keyArr(i)&"%'"
next
set rs=conn.execute(sql)
if t=1 then
%>
<table width="917" border="0" align="center" cellpadding="2" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td colspan="2" valign="top"><table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#F0F0F0">
<tr>
<td bgcolor="#EBEBEB"><table width="98%" border="0" cellpadding="10" cellspacing="0">
<tr>
<td> <b>关于先泽电器开关“<font color="#FF0000"><%=key%></font>”的搜索结果:</b></td>
</tr>
</table></td>
</tr>
<tr>
<td valign="top" bgcolor="#FFFFFF">
<tr>
<td><table width="155" border="0" cellpadding="0" cellspacing="0">
<tr>
<%
dim i
i=1
do while not rs.eof
%>
<td><table width="100%" border="0" cellpadding="5" cellspacing="1">
<tr>
<td><div align="center"><a href="showshop.asp?id=<%=rs("id")%>" class="img"><img src="<%=rs("img")%>" width="128" height="100" /></a></div></td>
</tr>
<tr>
<td><div align="center"><a href="showshop.asp?id=<%=rs("id")%>"><%=replace(rs("title"),Request.Form("key"),"<font color=red>"&Request.Form("key")&"</font>")%></a></div></td>
</tr>
</table></td>
<%
if i mod 6=0 then
response.Write "<tr>"
end if
i=i+1
rs.movenext
loop
%>
</tr>
</table></td>
</tr>
</table>
<%else%>
<table width="917" border="0" align="center" cellpadding="2" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td colspan="2" valign="top"><table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#F0F0F0">
<tr>
<td bgcolor="#EBEBEB"><table width="98%" border="0" cellpadding="10" cellspacing="0">
<tr>
<td> <b>关于先泽电器开关“<font color="#FF0000"><%=key%></font>”的搜索结果:</b></td>
</tr>
</table></td>
</tr>
<tr>
<td>
<%
if rs.eof then
response.write ("没有搜索到相关内容!")
else
%>
<div class="box14">
<ul>
<% do while not rs.eof %>
<%
title=rs("title")
for i=0 to ubound(keyArr)
keyArr=split(Request.Form("key")," ")
title=replace(title,keyArr(i),"<font color=red>"&keyArr(i)&"</font>")
next
%>
<li> <a href="shownews.asp?id=<%=rs("id")%>"><%=title%></a><img src="/images/search_top.gif" alt="哪位高手能为一个刚接触ASP的新手完成站内搜索结果分页处理,感谢"title")%>" /> <%=rs("data")%></li>
<%rs.movenext
loop %>
</ul>
</div>
</td>
</tr>
</table></td>
</tr>
</table>
<%
end if
end if
%></td>
</tr>
</table>
</tr>
<tr>
<td height="20">
<div style="border-bottom:#005AB5 5px solid;"></div></td>
</tr>
<!--#include file="foot.asp" -->
</body>
</html>
[解决办法]
传值过去,然后根据 传过来的值,提取数据,再分页!
//接收 传过来的 类型ID
int typeID = Convert.ToInt32(Request.QueryString["id"].ToString());
this.Label1.Text = type.getModel(typeID).typeName;
string strWhere = " where typeID='" + typeID + "'";
this.Repeater1.DataSource = shop.GetList(strWhere);
this.Repeater1.DataBind();
//如果是用 session传值的方法
string name=session["name"];
string strWhere = " where name='" + name+ "'";
this.Repeater1.DataSource = shop.GetList(strWhere);
this.Repeater1.DataBind();
[解决办法]
作为新手,有不会的提出来求教,目的应该是让自己进步提高,然后自己去完成自己该做的事.
若是按照你这种说法,不会就只是让别人替你完成,那劝你趁早玩别的去,别污辱这个行当.
[解决办法]