15. april 2003 - 15:33Der er
17 kommentarer og 1 løsning
Flet ind i Reponse.Write
Hejsa NG.
Hvordan fletter jeg denne her kode: <% AntalKommentarer=0 if isNumeric(ID) then Set rs1=objConn.Execute("SELECT COUNT(*) FROM commentsnyhed where nyhedid=" & ID) AntalKommentarer=rs1(0).Value Response.Write "(<font color='#FF9C00'>" & AntalKommentarer & "</font>)" end if %>
Ind i denne her kode:
<% intPage = Request("page") If isNumeric(intPage) = False Or intPage < 1 Then intPage = 1 End If
Set rs = Server.CreateObject("ADODB.RecordSet") strSQL = "SELECT * FROM arkiv ORDER BY id DESC" strDSN = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&Server.MapPath("../../db/data.mdb") rs.Open strSQL, strDSN, 1 If Not (rs.BOF Or rs.EOF) Then rs.PageSize = 10 rs.AbsolutePage = intPage intRecCount = rs.PageSize intPageCount = rs.PageCount Response.Write "<p><b>Side " & intPage & " af " & intPageCount & "</b></p>" Do While Not rs.EOF And intRecCount > 0
<% sub fletmig() AntalKommentarer=0 if isNumeric(ID) then Set rs1=objConn.Execute("SELECT COUNT(*) FROM commentsnyhed where nyhedid=" & ID) AntalKommentarer=rs1(0).Value Response.Write "(<font color='#FF9C00'>" & AntalKommentarer & "</font>)" end if end sub %>
<% sub fletmig() AntalKommentarer=0 if isNumeric(ID) then Set rs1=objConn.Execute("SELECT COUNT(*) FROM commentsnyhed where nyhedid=" & ID) AntalKommentarer=rs1(0).Value Response.Write "(<font color='#FF9C00'>" & AntalKommentarer & "</font>)" end if end sub
intPage = Request("page") If isNumeric(intPage) = False Or intPage < 1 Then intPage = 1 End If
Set rs = Server.CreateObject("ADODB.RecordSet") strSQL = "SELECT * FROM arkiv ORDER BY id DESC" strDSN = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&Server.MapPath("../../db/data.mdb") rs.Open strSQL, strDSN, 1 If Not (rs.BOF Or rs.EOF) Then rs.PageSize = 10 rs.AbsolutePage = intPage intRecCount = rs.PageSize intPageCount = rs.PageCount Response.Write "<p><b>Side " & intPage & " af " & intPageCount & "</b></p>" Do While Not rs.EOF And intRecCount > 0
<% sub fletmig() AntalKommentarer=0 if isNumeric(ID) then Set rs1=objConn.Execute("SELECT COUNT(*) FROM commentsnyhed where nyhedid=" & ID) AntalKommentarer=rs1(0).Value Response.Write ("<font color='#FF9C00'>" & AntalKommentarer & "</font>") end if end sub
intPage = Request("page") If isNumeric(intPage) = False Or intPage < 1 Then intPage = 1 End If
Set rs = Server.CreateObject("ADODB.RecordSet") strSQL = "SELECT * FROM arkiv ORDER BY id DESC" strDSN = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&Server.MapPath("../../db/data.mdb") rs.Open strSQL, strDSN, 1 If Not (rs.BOF Or rs.EOF) Then rs.PageSize = 10 rs.AbsolutePage = intPage intRecCount = rs.PageSize intPageCount = rs.PageCount Response.Write "<p><b>Side " & intPage & " af " & intPageCount & "</b></p>" Do While Not rs.EOF And intRecCount > 0
Ja den kan jeg ikke hjælpe dig med. Nu virker flettningen, det der er problemet nu er den kode du vill flette ind. Prøv eventuelt det her istedet: Da det kan være at det er fordi vi har lavet det i en sub. <%
intPage = Request("page") If isNumeric(intPage) = False Or intPage < 1 Then intPage = 1 End If
Set rs = Server.CreateObject("ADODB.RecordSet") strSQL = "SELECT * FROM arkiv ORDER BY id DESC" strDSN = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&Server.MapPath("../../db/data.mdb") rs.Open strSQL, strDSN, 1 If Not (rs.BOF Or rs.EOF) Then rs.PageSize = 10 rs.AbsolutePage = intPage intRecCount = rs.PageSize intPageCount = rs.PageCount Response.Write "<p><b>Side " & intPage & " af " & intPageCount & "</b></p>" Do While Not rs.EOF And intRecCount > 0
Ja men jeg tror dit problem er ikke med fglettningen men med den del af koden hvor der står: Set rs1=objConn.Execute
Men da jeg ikke ved hvad du vil med den linie kan jeg kun gætte. Men prøv eventuelt med denne kode:
<%
intPage = Request("page") If isNumeric(intPage) = False Or intPage < 1 Then intPage = 1 End If
Set rs = Server.CreateObject("ADODB.RecordSet") strSQL = "SELECT * FROM arkiv ORDER BY id DESC" strDSN = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&Server.MapPath("../../db/data.mdb") rs.Open strSQL, strDSN, 1 If Not (rs.BOF Or rs.EOF) Then rs.PageSize = 10 rs.AbsolutePage = intPage intRecCount = rs.PageSize intPageCount = rs.PageCount Response.Write "<p><b>Side " & intPage & " af " & intPageCount & "</b></p>" Do While Not rs.EOF And intRecCount > 0
intPage = Request("page") If isNumeric(intPage) = False Or intPage < 1 Then intPage = 1 End If
Set rs = Server.CreateObject("ADODB.RecordSet") strSQL = "SELECT * FROM arkiv ORDER BY id DESC" strDSN = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&Server.MapPath("../../db/data.mdb") rs.Open strSQL, strDSN, 1 If Not (rs.BOF Or rs.EOF) Then rs.PageSize = 10 rs.AbsolutePage = intPage intRecCount = rs.PageSize intPageCount = rs.PageCount Response.Write "<p><b>Side " & intPage & " af " & intPageCount & "</b></p>" Do While Not rs.EOF And intRecCount > 0
intRecCount = intRecCount - 1 rs.MoveNext Loop End If rs.Close rs1.Close Set rs = Nothing Set rs1 = Nothing Response.Write "<p>Gå til side " For intNum = 1 To intPageCount Response.Write "<a href=newsarkiv.asp?page=" & intNum & ">" & intNum & "</a> " Next
Response.Write "<p>" If Clng(intPage) > 1 Then Response.Write "<a href=newsarkiv.asp?page=" & intPage - 1 & "><<</a>" Else Response.Write "<<" End If
Response.Write " "
If Clng(intPage) < Clng(intPageCount) Then Response.Write "<a href=newsarkiv.asp?page=" & intPage + 1 & ">>></a> " Else Response.Write ">>" End If %>
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.