Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 14
  1. #1
    Utente di HTML.it
    Registrato dal
    Nov 2004
    Messaggi
    1,627

    Impaginare dati da database

    salve a tutti!
    ho un picolo problema con l'impaginazione dei dati prelevati da un database.
    Il codice l'ho recuperato da uno script in rete, e modificato a seconda delle mie esigenze.
    Ho un catalogo, il quale visualizza i prodotti uno sotto l'altro, io volevo far si che che preimpostando una larghezza fissa che sarà opportunamente studiata in base ai prodotti (Es. 500px) mi inserisse i prodotti,uno difianco all'altro...ma non non vengo fuori...vi posto la aprte del codice in questione..

    Vi premetto che sono riuscito ad ottnere l'affiancamento dei prodotti...levando il <TD> dal dato che prelevavo dal database...solo che io volevo comunque riuscire ad impaginarli in una cella

    <table border="1" width="500" cellspacing="0" cellpadding="3" align="center" bordercolor="#CCCCCC">
    <tr>
    <tr bgcolor="<%=Tabella_Colore_Cella%>">
    <td align="center" bgcolor="#CCCCCC">Nome</td>
    </tr>
    <%
    If (QSSCategoria = "") AND (QSCategoria = "") AND (QSQuery = "") Then
    Response.Redirect Request.ServerVariables("HTTP_REFERER")
    Else
    '---Stampo a video i prodotti delle categorie richieste
    Set RS = Server.CreateObject("ADODB.RecordSet")
    RS.PageSize = MaxProdottiPerPagina

    If QSQuery <> "" Then
    QSQuery = Replace(QSQuery, "'", "''")
    ArrQuery = Split(QSQuery, " ")
    SQL = " SELECT * FROM Prodotti WHERE "
    For i = 0 to UBound(ArrQuery, 1)
    SQL = SQL & "(Prodotto LIKE '%" & ArrQuery(i) & "%' OR PDescrizione LIKE '%" & ArrQuery(i) & "%' OR GDescrizione LIKE '%" & ArrQuery(i) & "%') AND "
    Next
    SQL = SQL & "Cancellato = False"
    RS.Open SQL, Conn, 1
    Else
    If (QSCategoria = "") Then
    SQL = " SELECT * FROM Prodotti WHERE SCategoria = "& [QSSCategoria] &" AND Categoria = 0 AND Cancellato = False "
    RS.Open SQL, Conn, 1
    End If

    If (QSCategoria <> "") Then
    SQL = " SELECT * FROM Prodotti WHERE Categoria = "& [QSCategoria] &" AND Cancellato = False"
    RS.Open SQL, Conn, 1
    End If
    End If

    If Not RS.EoF Then
    RS.MoveFirst
    RS.AbsolutePage = QSPg

    If QSPg <> 1 Then
    Footer = "" & PrimaPagina & " "
    Else
    Footer = PrimaPagina & " "
    End If

    For I = 1 To RS.PageCount
    If I = QSPg Then
    Footer = Footer & I & " "
    Else
    Footer = Footer & ""& I &" "
    End If
    Next

    If QSPg <> RS.PageCount Then
    Footer = Footer & "" & UltimaPagina & ""
    Else
    Footer = Footer & UltimaPagina
    End If

    For I = 1 To RS.PageSize
    If RS.EOF Then Exit For
    %>

    <tr bgcolor="<%=Tabella_Colore_Cella%>">
    <td width="75" valign="top">




    "><%=RS("Prodotto")%></td>
    </tr>
    <%
    RS.MoveNext
    Next
    Else
    %>
    <tr bgcolor="<%=Tabella_Colore_Cella%>">
    <td colspan="10" align="center">

    <%=NoRecordTrovati%>
    </td>
    </tr>
    <%
    End If
    End If
    RS.Close
    %>
    </table>

  2. #2
    Utente di HTML.it
    Registrato dal
    Nov 2004
    Messaggi
    1,627
    ciao a tutti....ho risolto parte del mio problema
    riesco ad affiancare il i vari prodotti..però me li mette tutti in fila..invece..io volevo che qaundo la tabella finisce mi passase alla riga sotto...posto il codice


    <table border="1" width="500" cellspacing="0" cellpadding="3" align="center" bordercolor="#CCCCCC">

    <%
    If (QSSCategoria = "") AND (QSCategoria = "") AND (QSQuery = "") Then
    Response.Redirect session("referer")
    Else
    '---Stampo a video i prodotti delle categorie richieste
    Set RS = Server.CreateObject("ADODB.RecordSet")
    RS.PageSize = MaxProdottiPerPagina

    'MODIFICA DELLA SB SOFTWARE PER IL PREZZO MAX.
    if request.form("select") <> "" AND request.form("select") <> "" then
    If (QSCategoria = "") Then
    SQL = " SELECT * FROM Prodotti WHERE SCategoria = "& [QSSCategoria] &" AND Categoria = 0 AND Cancellato = False "
    If Session("Rivenditore") = True then
    SQL = SQL & "AND cLng(RPrezzo) <= "& cLng(FormattaPrezzoPerDB(request.form("select"))) &" "
    else
    SQL = SQL & "AND cLng(CPrezzo) <= "& cLng(FormattaPrezzoPerDB(request.form("select"))) &" "
    End if
    RS.Open SQL, Conn, 1
    End If

    If (QSCategoria <> "") Then
    SQL = " SELECT * FROM Prodotti WHERE Categoria = "& [QSCategoria] &" AND Cancellato = False "
    If Session("Rivenditore") = True then
    SQL = SQL & "AND cLng(RPrezzo) <= "& cLng(FormattaPrezzoPerDB(request.form("select"))) &" "
    else
    SQL = SQL & "AND cLng(CPrezzo) <= "& cLng(FormattaPrezzoPerDB(request.form("select"))) &" "
    End if
    RS.Open SQL, Conn, 1
    End If

    else

    If (QSCategoria = "") Then
    SQL = " SELECT * FROM Prodotti WHERE SCategoria = "& [QSSCategoria] &" AND Categoria = 0 AND Cancellato = False "
    RS.Open SQL, Conn, 1
    End If

    If (QSCategoria <> "") Then
    SQL = " SELECT * FROM Prodotti WHERE Categoria = "& [QSCategoria] &" AND Cancellato = False"
    RS.Open SQL, Conn, 1
    End If
    End If

    If Not RS.EoF Then
    RS.MoveFirst
    RS.AbsolutePage = QSPg

    If QSPg <> 1 Then
    Footer = "" & PrimaPagina & " "
    Else
    Footer = PrimaPagina & " "
    End If

    For I = 1 To RS.PageCount
    If I = QSPg Then
    Footer = Footer & I & " "
    Else
    Footer = Footer & ""& I &" "
    End If
    Next

    If QSPg <> RS.PageCount Then
    Footer = Footer & "" & UltimaPagina & ""
    Else
    Footer = Footer & UltimaPagina
    End If

    For I = 1 To RS.PageSize
    If RS.EOF Then Exit For
    %>


    <td bgcolor="<%=Tabella_Colore_Cella%>" width="135" valign="top"><a href="scheda.asp?id=<%=RS("ID")%>"><img src="../
    <%
    If RS("PFoto") <> ("public/imgprodotti/") Then
    Response.Write RS("PFoto")
    Else
    Response.Write Img_NonDisponibile_P
    End If
    %>
    " width="<%=PFoto_Larghezza%>" height="<%=PFoto_Altezza%>" border="0"></a>
    <%=RS("nome")%>
    <%=RS("eta")%>
    <%=RS("provincia")%>
    <%=RS("altezza")%>
    </td>






    <%
    RS.MoveNext
    Next
    %>


    </table>

  3. #3
    Prima del ciclo do inizializzi una variabile contatore uguale a 1, ad esempio:
    codice:
    cont = 1
    dentro al ciclo fai un controllo, del tipo, se cont è uguale a 4 (supponendo che tu voglia 4 prodotti per riga), allora scrivi un bel ritorno a capo (o chiudi la tr e ne apri un'altra) e reimposti cont = 1.
    codice:
    do while not rs.eof
    ' qui scrivi i dati dei prodotti
    if cont = 4 then
    response.write "</tr>"
    response.write "<tr>"
    cont = 1
    else
    cont = cont + 1
    end if
    rs.moveNext
    loop
    end if

  4. #4
    Utente di HTML.it
    Registrato dal
    Nov 2004
    Messaggi
    1,627
    ho fatto così

    %>

    <%
    conta = 0
    Do While NOT RS.EOF
    conta = conta + 1
    if conta = 4 then
    conta = 1
    %>
    </tr>
    <tr>
    <%
    end if
    %>


    <td bgcolor="<%=Tabella_Colore_Cella%>" width="135" valign="top"><a href="scheda.asp?id=<%=RS("ID")%>"><img src="../
    <%
    If RS("PFoto") <> ("public/imgprodotti/") Then
    Response.Write RS("PFoto")
    Else
    Response.Write Img_NonDisponibile_P
    End If
    %>
    " width="<%=PFoto_Larghezza%>" height="<%=PFoto_Altezza%>" border="0"></a>
    <%=RS("nome")%>
    <%=RS("eta")%>
    <%=RS("provincia")%>
    <%=RS("altezza")%>
    </td>





    <%
    RS.MoveNext
    Loop
    %>
    <%
    RS.MoveNext
    Next
    %>


    praticamente funziona...ogni 4 và a capo..ma il problema...è che in teoria però dovrebbero visualizzarsi un tot di prodotti per pagina...e poi creare una pagina sucessiva. Ma non avviene...e in più mi dà quet'errore




    Visualizza i prodotti per un prezzo massimo di :

    ADODB.Recordset error '800a0bcd'

    Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

    inc_catalogo.asp, line 251

  5. #5
    Prima di conta = 0 metti if not rs.eof then
    dopo
    Rs.Movenext
    next
    metti end if

  6. #6
    Utente di HTML.it
    Registrato dal
    Nov 2004
    Messaggi
    1,627
    con una cosa così

    if not rs.eof then
    conta = 0
    Do While NOT RS.EOF
    conta = conta + 1
    if conta = 6 then
    conta = 1



    mi dà quest'errore

    Microsoft VBScript compilation error '800a041f'

    Unexpected 'Next'

    /inc_catalogo.asp, line 226

    Next
    ^

  7. #7
    Scrivi il codice di tutta la pagina.

  8. #8
    Utente di HTML.it
    Registrato dal
    Nov 2004
    Messaggi
    1,627
    '---Dichiarazione variabili
    Dim SQL, RS, I, Footer, RStip, Index, ArrQuery, nome, eta, provincia, regione, nazione, altezza, conta

    If (QSSCategoria <> "") Or (QSQuery <> "") Then
    Dim smSQLCat, smRSCat, smscat, smcat, smdovesei

    if QSSCategoria <>"" then
    smSQLCat = " SELECT ID, SCategoria FROM SCategorie where ID="&Cint(QSSCategoria)
    smscat=""
    Set smRScat = Conn.Execute(smSQLCat)
    If Not smRSCat.EOF Then
    smscat=smRScat("Scategoria")
    end if
    smRSCat.close
    end if

    if QSCategoria <>"" then
    smSQLCat = " SELECT * FROM Categorie where ID="&Cint(QSCategoria)
    smcat=""
    Set smRScat = Conn.Execute(smSQLCat)
    If Not smRSCat.EOF Then
    smcat=smRScat("Categoria")
    end if
    smRSCat.close
    end if

    smdovesei="Hai selezionato il pulsante"

    if smscat<>"" then
    smdovesei=smdovesei&": "&smscat&""
    end if

    if smcat<>"" then
    smdovesei=smdovesei&" , "&smcat&""
    end if

    response.write(smdovesei)

    %>
    </font>[/b]<font size="3"> </font>

    <p align="justify">
    <%=Head_Catalogo%>



    <table width="100%" border="0" cellspacing="0" cellpadding="3" bordercolordark="#E5E5E5" bordercolorlight="#000000" border="1">
    <tr><td bgcolor="<%=Tabella_Colore_Cella%>" align="justify">


    <%
    SQLCat = " SELECT ID, SCategoria FROM SCategorie "
    Set RScat = Conn.Execute(SQLCat)

    If Not RSCat.EOF Then
    SCatArr = RScat.GetRows

    '---Stampo a video le scategorie ed eventuali categorie
    If QSSCategoria <> "" Then
    SQLCat = " SELECT ID, Categoria FROM Categorie WHERE SCategoria = " & QSSCategoria
    Set RSCat = Conn.Execute(SQLCat)

    If Not RSCat.EOF Then
    CatArr = RSCat.GetRows
    BoolCategorie = True
    Else
    BoolCategorie = False
    End If

    RSCat.Close
    End If

    For Icat = 0 to UBound(SCatArr, 2)
    %>

    <%
    If CStr(SCatArr(0,ICat)) = QSSCategoria Then
    If boolCategorie Then
    For K = 0 To UBound(CatArr,2)
    %>
    [img]<%=Path_Img%>catalogo_frecciadx.gif[/img]
    </font>
    <a href="catalogo.asp?scat=<%=SCatArr(0,ICat)%>&cat=< %=CatArr(0,k)%>">
    <%=CatArr(1,k)%></font></a><font color="#000080">

    <%
    Next
    End If
    End If
    Next
    Else
    %>
    <%=NoCategoria%>

    <%
    End If
    %>
    </font>
    </td>
    </table>



    </p>

    <table border="1" width="500" cellspacing="0" cellpadding="3" align="center" bordercolor="#CCCCCC">

    <%
    If (QSSCategoria = "") AND (QSCategoria = "") AND (QSQuery = "") Then
    Response.Redirect session("referer")
    Else
    '---Stampo a video i prodotti delle categorie richieste
    Set RS = Server.CreateObject("ADODB.RecordSet")
    RS.PageSize = MaxProdottiPerPagina

    'MODIFICA DELLA SB SOFTWARE PER IL PREZZO MAX.
    if request.form("select") <> "" AND request.form("select") <> "" then
    If (QSCategoria = "") Then
    SQL = " SELECT * FROM Prodotti WHERE SCategoria = "& [QSSCategoria] &" AND Categoria = 0 AND Cancellato = False "
    If Session("Rivenditore") = True then
    SQL = SQL & "AND cLng(RPrezzo) <= "& cLng(FormattaPrezzoPerDB(request.form("select"))) &" "
    else
    SQL = SQL & "AND cLng(CPrezzo) <= "& cLng(FormattaPrezzoPerDB(request.form("select"))) &" "
    End if
    RS.Open SQL, Conn, 1
    End If

    If (QSCategoria <> "") Then
    SQL = " SELECT * FROM Prodotti WHERE Categoria = "& [QSCategoria] &" AND Cancellato = False "
    If Session("Rivenditore") = True then
    SQL = SQL & "AND cLng(RPrezzo) <= "& cLng(FormattaPrezzoPerDB(request.form("select"))) &" "
    else
    SQL = SQL & "AND cLng(CPrezzo) <= "& cLng(FormattaPrezzoPerDB(request.form("select"))) &" "
    End if
    RS.Open SQL, Conn, 1
    End If

    else

    If (QSCategoria = "") Then
    SQL = " SELECT * FROM Prodotti WHERE SCategoria = "& [QSSCategoria] &" AND Categoria = 0 AND Cancellato = False "
    RS.Open SQL, Conn, 1
    End If

    If (QSCategoria <> "") Then
    SQL = " SELECT * FROM Prodotti WHERE Categoria = "& [QSCategoria] &" AND Cancellato = False"
    RS.Open SQL, Conn, 1
    End If
    End If

    If Not RS.EoF Then
    RS.MoveFirst
    RS.AbsolutePage = QSPg

    If QSPg <> 1 Then
    Footer = "" & PrimaPagina & " "
    Else
    Footer = PrimaPagina & " "
    End If

    For I = 1 To RS.PageCount
    If I = QSPg Then
    Footer = Footer & I & " "
    Else
    Footer = Footer & ""& I &" "
    End If
    Next

    If QSPg <> RS.PageCount Then
    Footer = Footer & "" & UltimaPagina & ""
    Else
    Footer = Footer & UltimaPagina
    End If

    For I = 1 To RS.PageSize
    If RS.EOF Then Exit For
    %>

    <%
    if not rs.eof then
    conta = 0
    Do While NOT RS.EOF
    conta = conta + 1
    if conta = 6 then
    conta = 1
    %>

    <tr>
    <%
    end if
    %>


    <td bgcolor="<%=Tabella_Colore_Cella%>" width="135" valign="top"><a href="scheda.asp?id=<%=RS("ID")%>"><img src="../
    <%
    If RS("PFoto") <> ("public/imgprodotti/") Then
    Response.Write RS("PFoto")
    Else
    Response.Write Img_NonDisponibile_P
    End If
    %>
    " width="<%=PFoto_Larghezza%>" height="<%=PFoto_Altezza%>" border="0"></a>
    <%=RS("nome")%>
    <%=RS("eta")%>
    <%=RS("provincia")%>
    <%=RS("altezza")%>
    </td>





    <%
    RS.MoveNext
    Loop
    %>



    </table>
    <%
    RS.MoveNext
    Next
    End If

    %>

    <%
    Else
    %>
    <tr bgcolor="<%=Tabella_Colore_Cella%>">
    <td colspan="5" align="center" height="18">

    <%=NoRecordTrovati%>
    </td>
    </tr>
    <%
    End If
    End If
    RS.Close
    %>

    <%
    End If
    %>
    <div align="center">


    <%=Footer%>
    </div>




    </p>

  9. #9
    Sposta l'end if dopo il loop precedente.
    Così:
    codice:
    For I = 1 To RS.PageSize
    If RS.EOF Then Exit For
    %>
    
    <%
    if not rs.eof then
    conta = 0
    Do While NOT RS.EOF
    conta = conta + 1
    if conta = 6 then
    conta = 1
    %>
    
    <tr>
    <%
    end if
    %>
    
    
    <td bgcolor="<%=Tabella_Colore_Cella%>" width="135" valign="top"><a href="scheda.asp?id=<%=RS("ID")%>"><img src="../
    <%
    If RS("PFoto") <> ("public/imgprodotti/") Then
    Response.Write RS("PFoto")
    Else
    Response.Write Img_NonDisponibile_P
    End If
    %>
    " width="<%=PFoto_Larghezza%>" height="<%=PFoto_Altezza%>" border="0"></a>
    <%=RS("nome")%>
    <%=RS("eta")%>
    <%=RS("provincia")%>
    <%=RS("altezza")%>
    </td>
    
    
    
    
    
    <%
    RS.MoveNext
    Loop
    End If
    %> 
    
    
    
    </table>
    <%
    RS.MoveNext
    Next
    %>

  10. #10
    Utente di HTML.it
    Registrato dal
    Nov 2004
    Messaggi
    1,627
    sempre quest'errore


    ADODB.Recordset error '800a0bcd'

    Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

    inc_catalogo.asp, line 226

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.