webForumDet fria alternativet

Dubbla uppdateringar

1 svar · 209 visningar · startad av emil

emilMedlem sedan apr. 2000106 inlägg
#1

Har en sida där jag hämtar information från en access databas och sen visar den senaste 3 nyhererna

-----------------------> kod

<%
mypage = Request("whichpage")
If mypage = "" then
mypage = 1
End If
mypagesize = 3

SQL = "Select * From Nyhet ORDER BY id DESC"

Set rstemp = Server.Createobject("ADODB.Recordset")
rstemp.cursorlocation = 3
rstemp.cachesize = 5
MdbFilePath = Server.MapPath("sevenet.mdb")
rstemp.open SQL, "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & MdbFilePath & ";"
If rstemp.EOF then
Response.write "Där fanns det ju inget... " & sok
Else
rstemp.movefirst
rstemp.pagesize = mypagesize
maxcount = Cint(rstemp.pagecount)
rstemp.absolutepage = mypage
howmanyrecs = 0
howmanyfields = rstemp.fields.count -1
Do While Not RStemp.EOF AND howmanyrecs < rstemp.pagesize
counter = counter + 1

Response.write "<tr bgcolor='" & e9e9e9 &"'><td ><b>" & RStemp("Rubrik") & "</td></tr>"
Response.write "<tr bgcolor='" & color & "'><td bgcolor=e9e9e9>" & RStemp("Av") & "</td></tr>"
Response.write "<tr bgcolor='" & color & "'><td>" & RStemp("Datum") & "</td></tr>"
Response.write "<tr bgcolor='" & color & "'><td bgcolor=e9e9e9>" & RStemp("Text") & "</td></tr>"
Response.write "<tr bgcolor='" & color & "'><td bgcolor=>" & RStemp("br") & "</td></tr>"

rstemp.movenext
howmanyrecs = howmanyrecs + 1
Loop
rstemp.close
Set rstemp = nothing
%>
<tr><td width="406"><hr></td></tr>
<tr><td width="406">
<%
If maxcount <> 0 then
response.write " Sida " & mypage & " av totalt " & maxcount & " sidor med nyheter. <br>" & sidor:
pad = "0"
scriptname = request.Servervariables("script_name")
for counter = 1 to maxcount
If counter >= 3 then
pad = ""
End If
ref = "<a href='" & scriptname & "?whichpage=" & counter & "&pagesize=" & mypagesize & "'>" & pad & counter & "</a> "
response.write ref & " "
if counter mod 3 = 0 then
response.write "<br>"
End If
Next
End If
End If
%>

<-----------------

sen har jag också en för sportresultat

----------------> kod

                           \<%

mypage = Request("lgif")
If mypage = "" then
mypage = 1
End If
mypagesize = 3

SQL = "Select * From Resultat ORDER BY id DESC"

Set lgiftemp = Server.Createobject("ADODB.Recordset")
lgiftemp.cursorlocation = 3
lgiftemp.cachesize = 5
MdbFilePath = Server.MapPath("sevenet.mdb")
lgiftemp.open SQL, "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & MdbFilePath & ";"
If lgiftemp.EOF then
Response.write "Där fanns det ju inget... " & sok
Else
lgiftemp.movefirst
lgiftemp.pagesize = mypagesize
maxcount = Cint(rstemp.pagecount)
rstemp.absolutepage = mypage
howmanyrecs = 0
howmanyfields = lgiftemp.fields.count -1
Do While Not lgiftemp.EOF AND howmanyrecs < lgiftemp.pagesize
counter = counter + 1

Response.write "<tr bgcolor='" & e9e9e9 &"'><td ><b>" & lgiftemp("Lag") & "</td></tr>"
Response.write "<tr bgcolor='" & color & "'><td bgcolor=e9e9e9>" & lgiftemp("Datum") & "</td></tr>"
Response.write "<tr bgcolor='" & color & "'><td bgcolor=e9e9e9>" & lgiftemp("Skyttar") & "</td></tr>"
Response.write "<tr bgcolor='" & color & "'><td bgcolor=>" & lgiftemp("br") & "</td></tr>"

lgiftemp.movenext
howmanyrecs = howmanyrecs + 1
Loop
lgiftemp.close
Set lgiftemp = nothing
%>
</b>
<tr><td width="406"><hr></td></tr>
<tr><td width="406">
<%
If maxcount <> 0 then
response.write " Sida " & mypage & " av " & maxcount & " med resultat. <br>" & sidor:
pad = "0"
scriptname = request.Servervariables("script_name")
for counter = 1 to maxcount
If counter >= 3 then
pad = ""
End If
ref = "<a href='" & scriptname & "?lgif=" & counter & "&pagesize=" & mypagesize & "'>" & pad & counter & "</a> "
response.write ref & " "
if counter mod 3 = 0 then
response.write "<br>"
End If
Next
End If
End If
%>

<-------------------------

problemet är att om man har tex 6 nyheter och 6 resultat, och man klickar för att komma till sida 2 på nyheter ( alltså visa nyheterna 3-6 ) så uppdateras även resultaten och visar 3-6 senaste resultaten, hur gör jag för att nyheterna endast skall uppdatera nyheterna och resultaten resultaten?

Tacksam för svar... mvh emil

BrimbaMedlem sedan dec. 19995 875 inlägg
#2

Kan det möjligvis ligga i att du har samma variabelnamn för både nyheter och resultat?

Jag skummade bara igenom, men såg att det var samma.
Detta bör innebära att när den skall hämta informationen om att du vill ha nästa resultat, får både resultat och nyheter samma värden, alltså blir det för båda nästa sida.

------------------
Mvh
Patrik
aka Brimba

129 ms totalt · 3 externa anrop · v20260731065814-full.fb544a5a
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
126 ms — hämta tråd, inlägg och bilagor (db)