Visualizzazione dei risultati da 1 a 10 su 10
  1. #1

    Notizie, cicli e database

    Ho necessità di costruire una pagina "notizie" con due righe e due colonne, in cui inserire il titolo, un'immagine, un testo-notizia, il link ad un sito esterno. Tutti questi dati li pesco da un database.
    Ho costruito il recordset, ma non so come inserire un ciclo per avere le notizie in due righe/due colonne.
    posto il codice:

    <%@LANGUAGE="VBSCRIPT"%>

    <%
    set Recordset1 = Server.CreateObject("ADODB.Recordset")
    Recordset1.ActiveConnection = MM_connNotizie1_STRING
    Recordset1.Source = "SELECT ArticleName, ArticleImageURL, ArticleLinkURL, ArticleActive, ArticleData FROM tblQNArticles ORDER BY ArticleData ASC"
    Recordset1.CursorType = 0
    Recordset1.CursorLocation = 2
    Recordset1.LockType = 3
    Recordset1.Open()
    Recordset1_numRows = 0
    %>
    <table width="100%" border="0" class="tabledot">
    <tr>
    <td width="10"></td>
    <td width="200">
    <div align="center">" target="_blank">[img]<%=(Recordset1.Fields.Item([/img]" border="0" alt="<%=(Recordset1.Fields.Item("ArticleName").Val ue)%>"></div>
    </td>
    <td width="40"></td>
    <td width="200">
    <div align="center">[img]../images/immagine2.jpg[/img]</div>
    </td>
    <td width="10"></td>
    </tr>
    <tr>
    <td width="10"></td>
    <td class="testo" width="200" valign="top"> <%=(Recordset1.Fields.Item("ArticleData").Value) %>[" class="linkregular" target="_blank">more]</td>
    <td width="40"></td>
    <td class="testo" width="200" valign="top">Notizia 2[more]
    </td>
    <td width="10"></td>
    </tr>
    <tr>
    <td width="10" height="10"></td>
    <td width="200" height="10"></td>
    <td width="40" height="10"></td>
    <td width="200" height="10"></td>
    <td width="10" height="10"></td>
    </tr>
    <tr>
    <td width="10"></td>
    <td width="200">
    <div align="center">[img]../images/immagine3.jpg[/img]</div>
    </td>
    <td width="40"></td>
    <td width="200">
    <div align="center">[img]../images/immagine4.jpg[/img]</div>
    </td>
    <td width="10"></td>
    </tr>
    <tr>
    <td width="10"></td>
    <td width="200">Notizia 3[more]
    </td>
    <td width="40"></td>
    <td width="200">Notizia 4[more]
    </td>
    <td width="10"></td>
    </tr>
    </table>
    <%
    Recordset1.Close()
    %>
    Qualche suggerimento? Grazie

  2. #2
    Più mi scervello e meno capisco
    Visualizzo sempre il primo record, ma degli altri tre non se ne parla.
    Ho cercato sul Forum qualche articolo sui cicli, qualcuno mi suggerisce un tutorial in rete?
    Oramai, ci penserò domattina
    Grazie

  3. #3
    Utente di HTML.it L'avatar di Lak3d
    Registrato dal
    Aug 2006
    Messaggi
    1,031
    se devi inserire UN testo, UN immagine, UNA notizia non c'è bisogno che fai nessun ciclo. Dopo la query vai sul record e stampi nelle celle che vuoi.

  4. #4
    Una sarebbe semplice. Vorrei inserire un "pacchetto notizia" (cioè Immagine con link, titolo, testo, link) su una cella specifica e ripeterla per tre volte, quindi:

    1 - Ultima notizia (pacchetto notizia)
    2 - Penultima notizia (idem)
    3 - Terz'ultima notizia (idem)
    4 - Quart'ultima notizia(idem)

    Devo fare un recordset per ogni pacchetto notizia , cioè rsNotizia1, rsNotizia2, etc?
    Questo è il dubbio

  5. #5
    Basta un recordset solo e utilizzi il ciclo

    Do While not Recordset1.Eof

    Recordset1.MoveNext
    Loop


    L'unico problema è sapere come devi trasferire le immagini. Se scegli semplicemente il nome in una combo o se devi fare un UPLOAD perché effettuare l'UPLOAD multiplo da parecchi problemi prima che funzioni perfettamente.

  6. #6
    Devo averne combinata una delle mie. L'errore che mi si mostra è:

    ADODB.Field error '800a0bcd'

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

    /pages/news-bottom.asp, line 23
    posto il codice:

    <%LANGUAGE="VBSCRIPT"%>

    <%
    set Recordset1 = Server.CreateObject("ADODB.Recordset")
    Recordset1.ActiveConnection = MM_connNotizie1_STRING
    Recordset1.Source = "SELECT ArticleName, ArticleImageURL, ArticleLinkURL, ArticleActive, ArticleData FROM tblQNArticles ORDER BY ArticleData ASC"
    Recordset1.CursorType = 0
    Recordset1.CursorLocation = 2
    Recordset1.LockType = 3
    Recordset1.Open()
    Recordset1_numRows = 0
    %>
    <%
    Do While not Recordset1.Eof

    Recordset1.MoveNext
    Loop
    %>
    <table width="100%" border="0" class="tabledot">
    <tr>
    <td width="10"></td>
    <td width="200">
    <div align="center">" target="_blank">[img]<%=(Recordset1.Fields.Item([/img]" border="0" alt="<%=(Recordset1.Fields.Item("ArticleName").Val ue)%>"></div>
    </td>
    <td width="40"></td>
    <td width="200">
    <div align="center"></div>
    </td>
    <td width="10"></td>
    </tr>
    <tr>
    <td width="10"></td>
    <td class="testo" width="200" valign="top"> <%=(Recordset1.Fields.Item("ArticleData").Value) %>[" class="linkregular" target="_blank">more]</td>
    <td width="40"></td>
    <td class="testo" width="200" valign="top"></td>
    <td width="10"></td>
    </tr>
    <tr>
    <td width="10" height="10"></td>
    <td width="200" height="10"></td>
    <td width="40" height="10"></td>
    <td width="200" height="10"></td>
    <td width="10" height="10"></td>
    </tr>
    <tr>
    <td width="10"></td>
    <td width="200">
    <div align="center"></div>
    </td>
    <td width="40"></td>
    <td width="200">
    <div align="center"></div>
    </td>
    <td width="10"></td>
    </tr>
    <tr>
    <td width="10"></td>
    <td width="200"></td>
    <td width="40"></td>
    <td width="200"></td>
    <td width="10"></td>
    </tr>
    </table>
    <%
    Recordset1.Close()
    %>

    Capissi almeno dove andare a parare...

  7. #7
    Le immagini le invio in upload in una cartella specifica in maniera manuale (leggi Filezilla); nel database, ho un campo con il loro percorso

  8. #8
    Hai combinato un pò di macello
    Guarda dove hai messo il MoveNext ed il Loop

    Poi dopo il Loop utilizzi il recordset, ma ovviamente essendo già a fine record ti da errore.
    Sposta Recordset1.MoveNext e Loop prima della close


    Do While not Recordset1.Eof

    Recordset1.MoveNext
    Loop
    %>
    <table width="100%" border="0" class="tabledot">
    <tr>
    <td width="10"> </td>
    <td width="200">
    <div align="center">" target="_blank">[img]<%=(Recordset1.Fields.Item([/img]" border="0" alt="<%=(Recordset1.Fields.Item("ArticleName").Val ue)%>"></div>
    </td>
    <td width="40"> </td>
    <td width="200">
    <div align="center"></div>
    </td>
    <td width="10"> </td>
    </tr>
    <tr>
    <td width="10"> </td>
    <td class="testo" width="200" valign="top"> <%=(Recordset1.Fields.Item("ArticleData").Value) %>[" class="linkregular" target="_blank">more]</td>
    <td width="40"> </td>
    <td class="testo" width="200" valign="top"> </td>
    <td width="10"> </td>
    </tr>

  9. #9
    Grazie della pazienza, ho scritto il codice (con le tue correzioni in questo modo):

    <%LANGUAGE="VBSCRIPT"%>

    <%
    set Recordset1 = Server.CreateObject("ADODB.Recordset")
    Recordset1.ActiveConnection = MM_connNotizie1_STRING
    Recordset1.Source = "SELECT ArticleName, ArticleImageURL, ArticleLinkURL, ArticleActive, ArticleData FROM tblQNArticles ORDER BY ArticleData ASC"
    Recordset1.CursorType = 0
    Recordset1.CursorLocation = 2
    Recordset1.LockType = 3
    Recordset1.Open()
    Recordset1_numRows = 0
    %>
    <%
    Do While not Recordset1.Eof

    Recordset1.MoveNext
    Loop %>
    <table width="100%" border="0" class="tabledot">
    <tr>
    <td width="10"> </td>
    <td width="200">
    <div align="center">" target="_blank">[img]<%=(Recordset1.Fields.Item([/img]" border="0" alt="<%=(Recordset1.Fields.Item("ArticleName").Val ue)%>"></div>
    </td>
    <td width="40"> </td>
    <td width="200">
    <div align="center"></div>
    </td>
    <td width="10"> </td>
    </tr>
    <tr>
    <td width="10"> </td>
    <td class="testo" width="200" valign="top"> <%=(Recordset1.Fields.Item("ArticleData").Value) %>[" class="linkregular" target="_blank">more]</td>
    <td width="40"> </td>
    <td class="testo" width="200" valign="top"> </td>
    <td width="10"> </td>
    </tr>
    </table>
    <%
    Recordset1.Close()
    %>

    ma ottengo questo errore :

    ADODB.Field error '800a0bcd'

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

    /pages/news-bottom.asp, line 22

    Forse sbaglio nel metodo...

  10. #10
    Perdona l'ignoranza,

    Sposta Recordset1.MoveNext e Loop prima della close
    quale close? Questa?

    <%
    Recordset1.Close()
    %>

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.