webForumDet fria alternativet

FSO med 9 per sida samt 3 per rad

ASP

2 svar · 330 visningar · startad av Asa

Medlem sedan dec. 20011 860 inlägg
Frågan#1

Har fso mad paging och vill nu dela upp så att det visas 3 per rad och då blir det 3 rader. Har en kod nu som visar rätt på sida 1 men på de andra sidorna så blir allt fel. Kan nån kika på min kod och ändra så det blir rätt?

<table width="100%" border="0">
<%Set strFSO = Server.CreateObject("Scripting.FileSystemObject")
Set Mapp   = strFSO.getFolder(Server.MapPath("bilder/"))

PS = 9  'Bilder per sida
PR = 3   'Bilder per rad
       
If Mapp.Files.Count Mod PS Then 
  Sidor = Mapp.Files.Count \ PS + 1 
Else 
  Sidor = Mapp.Files.Count \ PS 
End If

Sida = Request.QueryString("sida")
If Sida = "" Then 
  Sida = 1 
End If  
    
Start = (Sida - 1) * PS
Slut = Start + PS

If Mapp.Files.Count = 0 Then%>
  <tr><td>Inga bilder!</td><tr>
<%Else
  x=0
  y=0
  For Each File In Mapp.Files 
    If x < Start Then 
    ElseIf x < Slut Then
      If y = PR Then
        Response.Write "<tr>"
        y = 0
      End If%>
      <td width="33%" align="center">
        <img src="bilder/<%=File.Name%>">
      </td>
    <%Else 
      Exit For 
    End If 
    y=y+1
    x=x+1 
  Next
End If%>
</table>
<%If Sidor > 1 Then
  Response.Write "<table width=""100%"" border=""0""><tr>"
  If (Int(sida)) > 1 Then
    Response.Write "<td width=""50%""><a href=""bilder.asp?sida=" & (Int(sida)-1) & """><b>Förra</b></a></td>"
  Else
    Response.Write "<td width=""50%"">Förra</td>"
  End If
  If (Int(sida)) <> (Int(Sidor)) Then
    Response.Write "<td width=""50%"" align=""right""><a href=""bilder.asp?sida=" & (Int(sida)+1) & """><b>Nästa</b></a></td>"
  Else
    Response.Write "<td width=""50%"" align=""right"">Nästa</td>"
  End If
  Response.Write "</tr></table>"
End If%>
Medlem sedan juni 2002256 inlägg
#2
<table width="100%" border="0">
<%Set strFSO = Server.CreateObject("Scripting.FileSystemObject")
Set Mapp   = strFSO.getFolder(Server.MapPath("../mestfest/arkiv/tmp/Sommaravslut - 030802"))

PS = 9  'Bilder per sida
PR = 3   'Bilder per rad
       
If Mapp.Files.Count Mod PS Then 
  Sidor = Mapp.Files.Count \ PS + 1 
Else 
  Sidor = Mapp.Files.Count \ PS 
End If

If Request.Querystring("sida") Then 
  Sida = CInt(Request.Querystring("sida"))
Else
  Sida = 1 
End If  
    
Start = (Sida - 1) * PS
Slut = Start + PS

If Mapp.Files.Count = 0 Then%>
  <tr><td>Inga bilder!</td><tr>
<%Else
  n=0
  x=0
  y=0
  loopInit = False
  For Each File In Mapp.Files 
    If n >= Start AND n < Slut Then 
    loopInit = True
      If y = PR Then
        Response.Write "<tr>"
        y = 0
      End If%>
      <td width="33%" align="center">
        <img src="bilder/<%=File.Name%>">
      </td>
    <%
    x = x +1
    y = y +1
    Else 
      If loopInit Then Exit For
    End If 
  n = n +1
  Next
End If%>
</table>
<%If Sidor > 1 Then
  Response.Write "<table width=""100%"" border=""0""><tr>"
  If (Int(sida)) > 1 Then
    Response.Write "<td width=""50%""><a href=""bilder.asp?sida=" & (Int(sida)-1) & """><b>Förra</b></a></td>"
  Else
    Response.Write "<td width=""50%"">Förra</td>"
  End If
  If (Int(sida)) <> (Int(Sidor)) Then
    Response.Write "<td width=""50%"" align=""right""><a href=""bilder.asp?sida=" & (Int(sida)+1) & """><b>Nästa</b></a></td>"
  Else
    Response.Write "<td width=""50%"" align=""right"">Nästa</td>"
  End If
  Response.Write "</tr></table>"
End If%>

/r
Fixat buggen från att visa PS+1 bilder per sida till endast PS

Medlem sedan dec. 20011 860 inlägg
#3

Tackar sååå hemskt mycket! Funkar prima.

446 ms totalt · 4 externa anrop · v20260731065814-full.86ec41c2
126 ms — deklarationer (db)
0 ms — hämta statistik (cache)
317 ms — hämta tråd, inlägg och bilagor (db)
125 ms — ändringar (db)