Søgning og pagning
Jeg har et problem med en side som skal lave paging på min søgning. Dette gør den også fint, men jeg kan ikke komme videre til side 2.Kode:
<%
strKeyword = Trim(Request.Form("Keyword"))
if strKeyword = "" then strKeyword= Trim(Request.QueryString("strKeyword"))
If Len(strKeyword) = 0 Then
' Hvis der ikke er skrevet i feltet
Response.Clear
Response.Redirect("search.asp")
Else
' Hvis der er skrevet i feltet
strKeyword = Replace(strKeyword,"'","''")
End If
intPage = Request("page")
If isNumeric(intPage) = False Or intPage < 1 Then
intPage = 1
End If
Set rs = Server.CreateObject("ADODB.RecordSet")
strDSN = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & server.MapPath("/log/produkter.mdb") & "; password="
SQLstmt = "SELECT ID, Vintype, vol, aar, Vin, pris FROM vine WHERE"
SQLstmt = SQLstmt & " (Vintype LIKE '%" & strKeyword & "%')"
SQLstmt = SQLstmt & " OR (vol LIKE '%" & strKeyword & "%')"
SQLstmt = SQLstmt & " OR (aar LIKE '%" & strKeyword & "%')"
SQLstmt = SQLstmt & " OR (Vin LIKE '%" & strKeyword & "%')"
SQLstmt = SQLstmt & " OR (Pris LIKE '%" & strKeyword & "%')"
rs.Open SQLstmt, strDSN, 1
If Not (rs.BOF Or rs.EOF) Then
rs.PageSize = 20
rs.AbsolutePage = intPage
intRecCount = rs.PageSize
intPageCount = rs.PageCount
%>
<%
Do While Not rs.EOF And intRecCount > 0
intRecCount = intRecCount - 1
%>
<%
rs.MoveNext
Loop
End If
rs.Close
Set rs = Nothing
if request.querystring("execute") = "all" then
datestring = ""
else
datestring = "WHERE (date Like '%-"&ddate&"-"&yyear&"%')"
end if
%>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="580">
<tr>
<tr>
<td colspan="2"><img src="../image/sp.gif" width="1" height="1" align="bottom" alt=""></td>
</tr>
<td WIDTH="100" CLASS="sort10"><%
If Clng(intPage) > 1 Then
Response.Write "<a href=search.asp?page=" & intPage - 1 & "><IMG SRC=../IMAGE/pil2.gif BORDER=0 WIDTH=7 HEIGHT=9 ALIGN=bottom><IMG SRC=../IMAGE/pil2.gif BORDER=0 WIDTH=7 HEIGHT=9 ALIGN=bottom> Tilbage</a>"
Else
Response.Write " "
End If
%></TD>
<TD CLASS="sort10" ALIGN="Center" WIDTH="290"><%
Response.Write "<p>Gå til side "
For intNum = 1 To intPageCount
Response.Write " | <a href=search.asp?page="& intNum &">" & intNum & "</a>"
Next
Response.Write " | "
%></TD>
<TD ALIGN="right" CLASS="sort10" WIDTH="100">
<%
If Clng(intPage) < Clng(intPageCount) Then
Response.Write "<a href=search.asp?page=" & intPage + 1 & ">Frem <IMG SRC=../IMAGE/pil1.gif BORDER=0 WIDTH=7 HEIGHT=9 ALIGN=bottom><IMG SRC=../IMAGE/pil1.gif BORDER=0 WIDTH=7 HEIGHT=9 ALIGN=bottom></a> "
Else
Response.Write " "
End If
%>
</TD>
</tr>
</table>