Jeg benytter nedestående kode til at lave paging med, men det
tæller forkert forstået på den måde at der ved et lige sideantal
kommer en side for meget.
Jeg håber der er en venlig asp haj der kan gennemskue hvor fejlen
er.
<%
'Først skal vi have antallet af poster på den valgte kommune
sqlAntal = "SELECT COUNT(*) AS records FROM tbldebate WHERE
(comID='" & Request("kommune") & "' AND fldConfirmed='1')"
Set objRs1 = conDB.Execute(sqlAntal)
intRecords = int(objRs1("records"))
'Lukker recordset
objRs1.Close
Set objRs1 = Nothing
strKommune = Request("kommune")
'Variabler til query´et
intPage = Request.QueryString("page")
'Hvis intPage er tom tildeles den værdien 1
if intPage = "" OR not isNumeric(intPage) then
intPage = int(1)
else
'intPage er lig siden der vælges ved klik
intPage = int(intPage)
end if
'Der skal vises 3 indlæg pr side
intPageSize = int(3)
intStart = intPage*intPageSize
intStart = intStart-intPageSize
intPages = int(intRecords / intPageSize)+1
intValue = (intRecords - intStart)
If intPageSize > intValue Then
intPageSize = intValue
end if
'sql query til udvælgelse af data
sqlCom2 = "SELECT * FROM tbldebate WHERE (comID='" & strKommune &
"' AND fldConfirmed='1') LIMIT " & intStart & ", " & intPageSize
& ";"
Set objRs2 = conDB.Execute(sqlCom2)
'Hvis recordsettet er tomt
if objRs2.EOF or objRs2.BOF then
Response.Write "<table width='770' border='0'
cellpadding='1'>"
Response.Write "<tr>"
Response.Write "<td> </td>"
Response.Write "</tr>"
Response.Write "<tr><td align='left'><a
href='javascript:history.back()'
target='_self'>Tilbage</a></td></tr>"
Response.Write "<tr><td colspan='2'> </td></tr>"
Response.Write "<tr>"
Response.Write "<td>"
Response.Write "<p><h5><center>Der blev ikke fundet nogle
debat indlæg<p></center></h5>"
Response.Write "</td>"
Response.Write "</tr>"
Response.Write "</table>"
else
'Ellers udskriv data
Response.Write "<div align='center'><table width='600'
border='0' cellpadding='3' cellspacing='0'>"
Response.Write "<tr><td colspan='2'><a
href='javascript:history.back()'
target='_self'>Tilbage</a></td></tr>"
Response.Write "<tr><td colspan='2'> </td></tr>"
Response.Write "<tr><td colspan='2'>"
'Udskriver en sideliste
For i = 1 to intPages
if i = intPage then
Response.Write "<b>" & i & " </b>"
else
Response.Write " <a href='readcontribs.asp?page="
& i & "&kommune=" & strKommune & "' target='_self'>" & i &
"</a> "
end if
next
Response.Write "</td></tr>"
Response.Write "<tr><td colspan='2'> </td></tr>"
Do While Not objRs2.EOF
Response.Write "<tr>"
Response.Write "<td align='left'
valign='middle' class='readCon1'>Dato:</td><td align='left'
valign='middle' class='readCon2'>" & " " & objRs2("fldDate") &
"</td><td> </td></tr>"
Response.Write "<td align='left'
valign='middle' class='readCon1'>Navn:</td><td align='left'
valign='middle' class='readCon2'>" & " " & objRs2("fldName") &
"</td><td> </td></tr>"
Response.Write "<td align='left' valign='middle'
class='readCon1'>E-mail:</td><td align='left' valign='middle'
class='readCon2'>" & " " & objRs2("fldEmail") &
"</td><td> </td></tr>"
Response.Write "<td align='left' valign='middle'
class='readCon1'>Emne:</td><td align='left' valign='middle'
class='readCon2'>" & " " & objRs2("fldSubject") &
"</td><td> </td></tr>"
Response.Write "<td align='left' valign='top'
class='readCon1'>Indlæg:</td><td align='left' valign='top'
class='readCon3'>" & " " &
Trim(Replace(objRs2("fldContribution"), vbCrLf, "<br>")) &
"</td></tr>"
Response.Write "<td align='left' valign='top'
colspan='2' align='left'> </td>"
Response.Write "</tr>"
'flyt til næste record
objRs2.MoveNext
'Loop igennem databasen
Loop
Response.Write "<tr><td colspan='2'> </td></tr>"
Response.Write "<tr><td colspan='2'>"
'Udskriver en sideliste
For i = 1 to intPages
if i = intPage then
Response.Write "<b>" & i & " </b>"
else
Response.Write " <a href='readcontribs.asp?page=" &
i & "&kommune=" & strKommune & "' target='_self'>" & i &
"</a> "
end if
next
Response.Write "</td></tr>"
Response.Write "<tr><td colspan='2'> </td></tr>"
Response.Write "<tr><td colspan='2'><a
href='javascript:history.back()'
target='_self'>Tilbage</a></td></tr>"
Response.Write "</table></div>"
end if
'Lukker recordset
objRs2.Close
Set objRs2 = Nothing
%>
--
Vil du lære at kode HTML, XHTML, CSS, SSI eller ASP?
- Pædagogiske tutorials på dansk
- Kom godt i gang med koderne
KLIK HER! =>
http://www.html.dk/tutorials