Visualizzazione dei risultati da 1 a 8 su 8

Discussione: Paginazione Risultati

  1. #1

    Parinazione Risultati

    Ciao, ho un problema nel paginare i risultati di una SELECT. Ho cercato nel forum ma non sono riuscito a trovare un esempio semplice che mi possa fare capire come fare.
    In patrica io dovrei dividere su diverese pagine il risultato di una SELECT. Il codice delle pagina è il seguente. Help Me,
    Grazie a tutti.

    <%
    Set Conn=Server.CreateObject("ADODB.Connection")
    strConn="driver={Microsoft Access Driver (*.mdb)}; "
    strConn=strConn & " DBQ=" & Server.MapPath("/mdb-database/database.mdb")
    Conn.Open strConn
    sql = "SELECT * FROM auto"
    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.Open sql, conn
    do while not(rs.eof)
    %>
    <table width="750" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td height="173"><table width="782" height="146" border="0" align="center" cellpadding="0" cellspacing="0" id="link">
    <tr>
    <td width="173" rowspan="4"><table width="160" height="120" border="2" align="center" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC">
    <tr>
    <td width="167" align="center">">[img]<%=rs([/img]" alt="" name="img1" width="150" height="110" border="0" id="img1" /></td>
    </tr>
    </table></td>
    <td width="11" rowspan="4"></td>
    <td width="598" height="34"><table width="590" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td><span class="Stile2"><%=rs("modello")%></span></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td height="38"><table width="590" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td width="592" height="20"><span class="Stile3">Descrizione:</span></td>
    </tr>
    <tr>
    <td class="Stile5"><div class="Stile4"><%=rs("descrizione")%></div></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td height="20"><table width="590" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td width="610" class="Stile3">Prezzo:</td>
    </tr>
    <tr>
    <td class="Stile4"><%=rs("prezzo1")%></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td height="19"></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td height="2"><hr /></td>
    </tr>
    </table>
    <%
    rs.movenext
    loop
    rs.Close
    set rs = Nothing
    conn.Close
    set conn = Nothing
    %>

  2. #2

  3. #3
    ciao,
    ho visto l'esempio postato ma non riesco a modificare il mio seguendo quell'esempio,
    qualkuno conosce un' esempio più semplice o potrebbe aiutarmi
    Grazie anticipate.

  4. #4
    ciao a tutti, riguardo al mio problema ho quasi risolto, l'unico intoppo che mi rimane sono la numerazione delle pagine. Forse è poco chiaro ma capirete guardando il codice che vi posto

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Documento senza titolo</title>
    </head>

    <body>
    <%
    RecordsPerPagina = 3
    page = Request("page")
    if page="" then page=1

    Set Conn=Server.CreateObject("ADODB.Connection")
    strConn="driver={Microsoft Access Driver (*.mdb)}; "
    strConn=strConn & " DBQ=" & Server.MapPath("/mdb-database/database.mdb")
    Conn.Open strConn
    sql = "SELECT * FROM auto"
    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.Open sql, conn
    ' paginazione
    rs.PageSize = RecordsPerPagina

    If rs.Eof=True or rs.Bof=True then
    Response.Write "

    Nessun risultato trovato</P>"
    Else
    For i=1 to RecordsPerPagina
    if Not rs.EOF then %>

    <table width="750" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td height="173"><table width="782" height="146" border="0" align="center" cellpadding="0" cellspacing="0" id="link">
    <tr>
    <td width="173" rowspan="4"><table width="160" height="120" border="2" align="center" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC">
    <tr>
    <td width="167" align="center">">[img]<%=rs([/img]" alt="" name="img1" width="150" height="110" border="0" id="img1" /></td>
    </tr>
    </table></td>
    <td width="11" rowspan="4"></td>
    <td width="598" height="34"><table width="590" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td><span class="Stile2"><%=rs("modello")%></span></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td height="38"><table width="590" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td width="592" height="20"><span class="Stile3">Descrizione:</span></td>
    </tr>
    <tr>
    <td class="Stile5"><div class="Stile4"><%=rs("descrizione")%></div></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td height="20"><table width="590" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td width="610" class="Stile3">Prezzo:</td>
    </tr>
    <tr>
    <td class="Stile4"><%=rs("prezzo1")%></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td height="19"></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td height="2"><hr /></td>
    </tr>
    </table>





    <%
    'mostra record
    rs.MoveNext
    end if
    Next
    End if
    rs.Close
    set rs = Nothing
    conn.Close
    set conn = Nothing
    %>
    </body>
    </html>

    Come faccio a mettere i numeretti sotto per visualizzare gli altri record??? :master: :master:

    Help me please!!!

  5. #5
    Nessuno Può aiutarmi!!!!

  6. #6
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    Sostituisci questo blocco di codice:
    Codice PHP:
    <%
    'mostra record
    rs.MoveNext
    end if
    Next
    End if
    rs.Close
    set rs = Nothing
    conn.Close
    set conn = Nothing
    %> 
    con questo:
    Codice PHP:
    <%
    'mostra record
    rs.MoveNext
    end if
    Next
    End if

    Response.Write "

    [B]Pagine:[/B]"

    For pag= 1 to rs.PageCount
    if Cint(page) = pag then

    Response.Write "[b]"
    Response.Write "<A href='
    ?page=" & pag
    Response.write "'>"
    Response.Write pag
    Response.Write "</A> "
    Response.Write "[/b]"
    else
    Response.Write "<A href='
    ?page=" & pag
    Response.write "'>"
    Response.Write pag
    Response.Write "</A> "
    end if
    Next
    Response.Write "</P>"
    rs.Close
    set rs = Nothing
    conn.Close
    set conn = Nothing
    %> 
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

  7. #7
    Ciao andrea, grazie per la risposta ma purtroppo il problema sussiste. ho sostituito il codice che mi hai detto ma i numeri di pagina non compaiono ugualmente.

    Posto link per farti vedere meglio

    Form di ricerca

    http://www.fabriziocar.it/nuovo/ricerca/form2.asp

    Prova ad effettuare una ricerca nella pagina ricerca.asp che spunterà
    noterai che non compare nessun numero di pagine

    Posto nuovamente codice completo per venetuali miei errori

    Codice PHP:
                      <%
    RecordsPerPagina 
    page 
    Request("page"
    if 
    page="" then page=
    Dim condveicolo
    tipoveicolomarcaalimentazioneanno
    condveicolo 
    Replace(Request.Form("condveicolo"), "'""")
    tipoveicolo Replace(Request.Form("tipoveicolo"), "'""")
    alimentazione Replace(Request.Form("alimentazione"), "'""")
    anno Replace(Request.Form("anno"), "'""")
    marca Replace(Request.Form("marca"), "'""")

    Set Conn=Server.CreateObject("ADODB.Connection")
    strConn="driver={Microsoft Access Driver (*.mdb)}; "
    strConn=strConn " DBQ=" Server.MapPath("/mdb-database/database.mdb")
    Conn.Open strConn
    sql 
    "SELECT * FROM auto WHERE 1=1"
    if tipoveicolo <> "nullo" Then sql sql " AND tipoveicolo = '" tipoveicolo "' " 
    if condveicolo <> "nullo" Then sql sql " AND condveicolo = '" condveicolo "' "
    if marca <> "nullo" Then sql sql " AND marca = '" marca "' "
    if anno <> "nullo" Then sql sql " AND anno = '" anno "' "
    if alimentazione <> "nullo" Then sql sql " AND alimentazione = '" alimentazione "' "


    Set rs Server.CreateObject("ADODB.Recordset")
    rs.Open sqlconn
    ' paginazione 
    rs.PageSize = RecordsPerPagina 

    If rs.Eof=True or rs.Bof=True then 
    Response.Write "

    Nessun risultato trovato</P>" 
    Else 
    For i=1 to RecordsPerPagina 
    if Not rs.EOF then %>

                      </div>
                    </p>
                    <table width="660" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td height="173"><table width="650" height="146" border="0" align="center" cellpadding="0" cellspacing="0" id="link">
                    <tr>
                      <td width="173" rowspan="4"><table width="160" height="120" border="2" align="center" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC">
                        <tr>
                          <td width="167" align="center">[url="autodesc.asp?Id=<%=rs("]">[img]<%=rs([/img]" alt="" name="img1" width="150" height="110" border="0" id="img1" />[/url]</td>
                        </tr>
                      </table></td>
                      <td width="11" rowspan="4"></td>
                      <td width="598" height="34" bgcolor="#F2F2F2"><table width="460" border="0" align="center" cellpadding="0" cellspacing="0">
                          <tr>
                            <td><span class="Stile11"><%=rs("modello")%></span></td>
                          </tr>
                        </table></td>
                    </tr>
                    <tr>
                      <td height="38"><table width="460" border="0" align="center" cellpadding="0" cellspacing="0">
                          <tr>
                            <td width="592" height="25"><span class="Stile9">Descrizione:</span></td>
                          </tr>
                          <tr>
                            <td class="Stile5"><div class="Stile7"><%=rs("descrizione")%>ff</div></td>
                          </tr>
                      </table></td>
                    </tr>
                    <tr>
                      <td height="20"><table width="460" border="0" align="center" cellpadding="0" cellspacing="0">
                          <tr>
                            <td width="610" height="22" class="Stile9">Prezzo:</td>
                          </tr>
                          <tr>
                            <td class="Stile8">&euro; <%=rs("prezzo1")%></td>
                          </tr>
                      </table></td>
                    </tr>
                    <tr>
                      <td height="19"></td>
                    </tr>
                </table></td>
              </tr>
              <tr>
                <td height="2"><hr /></td>
              </tr>
            </table>
                    <div align="center">
                      <% 
    '
    mostra record 
    rs
    .MoveNext 
    end 
    if 
    Next 
    End 
    if 

    Response.Write "

    [B]Pagine:[/B]" 

    For pag1 to rs.PageCount 
    if Cint(page) = pag then 

    Response
    .Write "[b]" 
    Response.Write "<A href='?page=" pag 
    Response
    .write "'>" 
    Response.Write pag 
    Response
    .Write "</A> " 
    Response.Write "[/b]" 
    else 
    Response.Write "<A href='?page=" pag 
    Response
    .write "'>" 
    Response.Write pag 
    Response
    .Write "</A> " 
    end if 
    Next 
    Response
    .Write "</P>" 
    rs.Close 
    set rs 
    Nothing 
    conn
    .Close 
    set conn 
    Nothing 
    %> 
    Grazie ancora anticipatamente

  8. #8
    Nessuno riesce ad aiutarmi

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.