asp 分页中显示不正常

2024-11-22 10:13:34
推荐回答(4个)
回答1:

试试这个,如果是SQL数据库请把 # 改为 '
培训成绩应是数字型的,所以 S2 的左右的 '去掉.

<%
dim s1,s2,s3,sql,rs
s1= Trim(Request("培训学生"))
s2= Trim(Request("培训成绩"))
s3= Trim(Request("培训时间"))
if s1="" then s1=Trim(Request("s1"))
if s2="" then s2= Trim(Request("s2"))
if s3="" then s3=Trim(Request("s3"))

sql="select * from student"
if s1<>"" and s2<>"" and s3<>"" then
sql=sql & " where s_student='"&s1&"' and s_result="&s2&" and s_time=#"&s3&"#"
end if
if s1<>"" and s2 <> "" and s3="" then
sql=sql & " where s_student='"&s1&"' and s_result="&s2&" "
end if
if s1<>"" and s2 = "" and s3="" then
sql=sql & " where s_student='"&s1&"'"
end if
if s1="" and s2 <> "" and s3<>"" then
sql=sql & " where s_result="&s2&" and s_time=#"&s3&"#"
end if
if s1="" and s2 = "" and s3<>"" then
sql=sql & " where s_time=#"&s3&"#"
end if
if s1<>"" and s2 = "" and s3<>"" then
sql=sql & " where s_student='"&s1&"' and s_time=#"&s3&"#"
end if
if s1="" and s2 <> "" and s3="" then
sql=sql & " where s_result="&s2&""
end if

set rs=server.createobject("adodb.recordset")
Response.write sql
rs.open sql,conn,1,3

rs.pagesize=3
page=request("page")
if page="" then page=1
if cint(page)<="0" then page=1
if cint(page)>rs.pagecount then page=rs.pagecount
if not rs.eof then rs.absolutepage=cint(page)
%>



无标题文档














<%
for i=0 to rs.pagesize-1
if rs.bof or rs.eof then exit for
%>









<%
rs.movenext()
next
%>





按姓名查询结果如下:
序列培训学生培训成绩培训老师培训时间
<%=(rs.Fields.Item("编号").Value)%><%=(rs.Fields.Item("培训学生").Value)%><%=(rs.Fields.Item("培训成绩").Value)%><%=(rs.Fields.Item("培训老师").Value)%><%=(rs.Fields.Item("培训时间").Value)%>
上一页<%response.write("记录总数:"&rs.RecordCount)%>下一页



<%
rs.Close()
Set rs = Nothing
%>

回答2:

要在上一页和下一页的连接地方。加入索引..

1.

把s1= Trim(Request.Form("培训学生"))
s2= Trim(Request.Form("培训成绩"))
s3= Trim(Request.Form("培训时间"))
改为
s1= Trim(Request("培训学生"))
s2= Trim(Request("培训成绩"))
s3= Trim(Request("培训时间"))

2.在加入如下代码
&s1=<%=s1%>&s2=<%=s2%>&s3=<%=s3%>

完成代码:




你可以试试

回答3:

page=request("page") 应该是 request.QueryString("page")
如果是用form表单提交数据,那么获取数据就应该是request.Form("")
如果只是传输了单独的字符串,类似于...get.asp?id=3,就用request.QueryString("") 获取id的具体的值。
采用表单提交 就要有类似






表单内容

回答4:

sql="select * from student"

加一个 select * from student where 1=1

后面的 sql=sql+" and 条件"