Jag har ett bildarkiv där jag har gjort såhär för att bläddra genom bilderna.
Jag hämtar från db:n där nästa id är > respektive < än föregående ID i sql-frågan, det fungerar sålänge man inte bläddrar bakåt, då går den till 185 istället för 186 när ID:t är 187? Någon snäll själ som har lust att hjälpa mig?
if request.querystring("visa") = "nasta" then
SQL = "select * from anv_bilder where ID > " & request.querystring("bild") & " AND anvID = " & request.querystring("ID") & " limit 1"
set rs3 = connection.execute(SQL)
end if
if request.querystring("visa") = "foregaende" then
[b]SQL = "select * from anv_bilder where ID < " & request.querystring("bild") & " AND anvID = " & request.querystring("ID") & " limit 1"[/b]
set rs3 = connection.execute(SQL)
end if
if len(request.querystring("visa")) = 0 then
SQL = "select * from anv_bilder where ID = " & request.querystring("bild") & " limit 1"
set rs3 = connection.execute(SQL)
end if
bild = Request.QueryString("bild")
SQL = "select * from anv_bilder where anvID = " & request.querystring("ID") & " order by id"
set rs10 = connection.execute(SQL)
Set RS4 = Server.CreateObject("ADODB.Recordset")
SQL = "SELECT * FROM bild_komment WHERE bildID = " & RS10("ID") & " ORDER BY datum desc"
RS4.cursorLocation = 3
RS4.Open SQL, Connection, adOpenStatic, adLockOptimistic
dim nr
nr=1
do until cint(RS3("ID")) = cint(RS10("ID"))
RS10.MoveNext
nr=nr+1
loop
Set antBilder = Connection.Execute("Select Count(*) As antBilder FROM anv_bilder WHERE anvID = " & request.querystring("ID") & " order by id")
Set Number = Connection.Execute("Select Count(*) As AntalKomment FROM bild_komment WHERE bildID = " & RS3("ID"))
%>
<%=RS3("bildtext")%>
<img src="bilder/<%=RS("anvandarnamn")%>/<%=RS3("bild")%>" width="430" height="312" border="1">
<%
If (cint(nr)) = 1 then
Response.write "föregående"
else
Response.write "<a href='visabild.asp?ID=" & RS("ID") & "&bild=" & RS3("ID") &"&visa=foregaende'>föregående</a>"
end if
%>
<%
Response.Write "Bild <b>" & nr & "</b> av <b>" & antBilder("antBilder") & "</b>" %>
<%
if cint(nr) = cint(antBilder("antBilder")) then
Response.write "nästa"
else
Response.write "<a href='visabild.asp?ID=" & RS("ID") & "&bild=" & RS3("ID") &"&visa=nasta'>nästa</a>"
End If
%>