paginationasp-classic

asp pagination problem


Hi i have a problem with this asp pagination. it seems to be putting all the links in the one row, so i think it might have something to do with the check of the int i... but im not that familar with asp. can anyone shed any light on this problem.

the folders contain pdfs for each day of the month, named A08P2.pdf A09P2.pdf etc...

Thanks

i = 1
Set fc = f.Files 
Set ff = f.SubFolders 
For Each f1 in fc
intPage =  cint(mid(f1.name,2,2))

chrEdition = mid(f1.name,1,1)

if chrEdition = "A" then
    if i = 1 then
        Response.Write "<tr>"
    end if
        Response.Write "<td width='40' align='center'><a href=" & sUP & f1.name & " class='blue_11px'>" & intPage & "</a></td>"
    if i = 10 then
        Response.Write "</tr>"
        i = 0
    end if
end if

i = i + 1
Next  

Solution

  • You should move the incrementing of the i (i=i+1) inside the if...end if, since if i is 9 and you encounter two chrEditions that are not 'A' then i will become 11 and will never match the closing condition i=10:

    if chrEdition = "A" then
        if i = 1 then
                Response.Write "<tr>"
        end if
                Response.Write "<td width='40' align='center'><a href=" & sUP & f1.name & " class='blue_11px'>" & intPage & "</a></td>"
        if i = 10 then
                Response.Write "</tr>"
                i = 0
        end if
    
        i = i + 1
    end if