Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Jul 2003
    Messaggi
    50

    Problema visualizzazione risultati

    Con questo codice scansione le varie directori fino ad arrivare alle foto che prima vengono visualizzate in provini(link) e poi con una singolarmente ........il mio problema è che nn riesco a formattare cioè disporre in colonne i provini cosa che adesso nn fa perche me le incolonna verticalmente una sotto l'altra questo è il codice

    <%
    Dim ValidExt(4)
    ValidExt(0) = "jpg"
    ValidExt(1) = "gif"
    ValidExt(2) = "png"
    ValidExt(3) = "bmp"
    imgpath = "/Cairo/images/"
    path2= "\Cairo"
    Function STVGallery(path)
    On Error Resume Next
    Set FSO = Server.CreateObject("Scripting.FileSystemObject")
    root = Server.Mappath("/Cairo/foto/")
    url = Request.ServerVariables("/Cairo/foto/")
    webpath = left(url, instrrev(url, "/"))
    If path = "" or right(path, 1) = "/" or right(path, 1) = "\" then
    If instr(path, "/") > 0 then
    path = replace(path, "/", "\")
    End if
    If left(path, 1) <> "\" then
    path = "\" & path
    End if
    If right(path, 1) <> "\" then
    path = path & "\"
    End if
    If instr(path, "..") < 1 then
    uppath = left(replace(path, "\", "/"), instrrev(left(replace(path, "\", "/"), len(path)-1), "/"))
    If uppath = "" then
    uppath = "/"
    End if
    result = vbcrlf & "" & vbcrlf
    result = result & "<table border=""0"" cellspacing=""3"" cellpadding=""0"">" & vbcrlf
    result = result & " <tr>" & vbcrlf
    result = result & " <td width=""18"" align=""center"">[img][/img]</td>" & vbcrlf
    result = result & " <td nowrap></td>" & vbcrlf
    result = result & " </tr>" & vbcrlf
    result = result & " <tr>" & vbcrlf
    result = result & " <td colspan=""2"" style=""height: 10px""></td>" & vbcrlf
    result = result & " </tr>" & vbcrlf
    If FSO.FolderExists(root & path) then
    Set dir = FSO.GetFolder(root & path)
    Set subdirs = dir.SubFolders
    For each subdir in subdirs
    If err.Number = 0 then
    result = result & " <tr>" & vbcrlf
    result = result & " <td align=""center""></td>" & vbcrlf & " <td nowrap>" & subdir.name & "</td>" & vbcrlf

    result = result & " </tr>" & vbcrlf
    Else
    result = result & " <tr>" & vbcrlf
    result = result & " <td></td><td>" & err.Description & "</td>" & vbcrlf
    result = result & " </tr>" & vbcrlf
    err.Clear
    End if
    Next
    Set subdirs = Nothing
    Set dirfiles =dir.Files

    result = result & "
    " & vbcrlf

    For each dirfile in dirfiles
    cont=cont+1
    For ext = 0 to ubound(ValidExt)-1

    If instr(right(lcase(dirfile), 4), ValidExt(ext)) > 0 then

    If cont<6Then
    result = result & " </tr>" & vbcrlf
    result = result & "
    " & vbcrlf
    result = result & "

    " & vbcrlf

    End if

    result = result & "<align=""left"">[img][/img]</td>"& vbcrlf
    'result = result & " " & vbcrlf'
    End if
    'result = result & " </td>" & vbcrlf'
    Next
    Next
    Set dirfiles = Nothing
    Set dir = Nothing
    Else
    result = result & " <tr>" & vbcrlf
    result = result & " <td></td>" & vbcrlf
    result = result & " <td nowrap>Path not found</td>" & vbcrlf
    result = result & " </tr>" & vbcrlf
    End if
    result = result & "</table>" & vbcrlf
    result = result & "" & vbcrlf
    Else
    Response.Redirect(webpath)
    End if
    Else
    If instr(path, "/") > 0 then
    path = replace(path, "/", "\")
    End if
    If left(path, 1) <> "\" then
    path = "\" & path
    End if
    If instr(path, "..") < 1 then
    uppath = left(replace(path, "\", "/"), instrrev(left(replace(path, "\", "/"), len(path)-1), "/"))
    result = vbcrlf & "" & vbcrlf
    result = result & "<table border=""0"" cellspacing=""3"" cellpadding=""0"">" & vbcrlf
    result = result & " <tr>" & vbcrlf
    result = result & " <td width=""80"" height=""50"" nowrap align=""center"">[img][/img]</td>" & vbcrlf
    result = result & " <td nowrap></td>" & vbcrlf
    result = result & "
    " & vbcrlf
    result = result & " </tr>" & vbcrlf
    result = result & "</table>" & vbcrlf
    If uppath = "" then
    uppath = "/"
    End if
    If FSO.FileExists(root & path) then
    Set imgfile = FSO.GetFile(root & path)
    imgname = imgfile.Name
    result = result & "<p align=""center"">[img][/img]</p>" & vbcrlf
    'result= result &"<p align=""center"">"& imgname&"</p>"& vbcrlf'
    Set imgfile = Nothing
    dirpath = left(path, len(path)-len(imgname))
    Set dir = FSO.GetFolder(root & dirpath)
    Set dirfiles = dir.Files
    counter = 0
    For each dirfile in dirfiles
    For ext = 0 to ubound(ValidExt)-1
    If instr(right(lcase(dirfile), 4), ValidExt(ext)) > 0 then
    counter = counter + 1
    If instr(dirfile, imgname) > 0 then
    imgfileloc = counter
    End if
    End if
    Next
    Next
    counter = 0
    For each dirfile in dirfiles
    For ext = 0 to ubound(ValidExt)-1
    If instr(right(lcase(dirfile), 4), ValidExt(ext)) > 0 then
    counter = counter + 1
    If counter = imgfileloc-1 then
    prevfile = dirfile.name
    prevfileloc = counter
    End if
    If counter = imgfileloc+1 then
    nextfile = dirfile.name
    nextfileloc = counter
    End if
    End if
    Next
    Next
    Set dirfiles = Nothing
    Set dir = Nothing
    result = result & "<table width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0"">" & vbcrlf
    result = result & " <tr>" & vbcrlf
    result = result & " <td width=""50%"" nowrap>"
    If prevfile <> "" then
    result = result & "<nowrap align=""center"">[img][/img]"
    End if
    result = result & "</td>" & vbcrlf
    result = result & " <td width=""30%"" align=""right"">"
    If nextfile <> "" then
    result = result & "[img][/img]"
    End if
    result = result & "</td>" & vbcrlf
    result = result & " </tr>" & vbcrlf
    result = result & "</table>" & vbcrlf
    result = result & "" & vbcrlf
    Else
    If err.Number = 0 then
    result = result & "
    File not found"
    Else
    result = result & "
    " & err.Description
    err.Clear
    End if
    End if
    Else
    Response.Redirect(webpath)
    End if
    End if
    Set FSO = Nothing
    STVGallery = result
    End function
    %>


    grazie!

  2. #2
    se c'è una cosa che piace poco a chi risponde è leggere valangate di codice...

    se non ho capito male vuoi che metta tutto in una tabella di X colonne e Y righe (dove X è definito, e Y, come è ovvio, sarà inevitabile :P)

    immaginiamo che hai tutto in un array...
    impaginiamo mettendo tutto in una tabella da 3 colonne

    codice:
    <%
    tmparr = Array("imm1","imm2","imm3","imm4","imm5","imm6","imm7","imm8")
    
    dim postot, i ,colonne
    colonne = 3	'numero di colonne
    postot = 0
    response.write "<table>"
    while postot <= ubound(tmparr)
    	
    	response.write "<tr>"
    	
    	for i=1 to colonne
    		if postot > ubound(tmparr) then exit for
    		response.write "<td>"
    		response.write tmparr(postot)
    		response.write "</td>"
    		postot = postot + 1
    	next
    	
    	response.write "</tr>"
    	
    wend
    response.write "</table>"
    %>
    ora al posto di TMPARR devi usare il tuo array della lista dele immagini (creandolo alla fine per esempio), e in COLONNE ci metti il numero di colonne che ti servono

    altrimenti puoi effettuare l'aggiunta delle celle onthefly, tenendo conto della posizione di colonna (e se ha superato un valore COLONNE, chiudere il </tr> e aprirne un'altro)

    il codice non ho voglia di leggerlo :P
    ma la modifica è una cosa semplice
    san imente saluta

    * http://simonecingano.it *

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.