Visualizzazione dei risultati da 1 a 3 su 3

Discussione: Problema paginazione

  1. #1

    Problema paginazione

    Ho un problema con la paginazione dove spesso la paginazione mi fa vedere un'ultima pagina dove però il contenuto è vuoto.

    Del tipo avrei 3 pagine piene con i risultati ma invece mi fa vedere la pagina 4, se clicco non mi fa vedere nulla, dato che sempra che il recordset sia arrivato alal fine.

    Vi scrivo i codici per la sql che genero:

    codice:
    		Set brandRS = Server.CreateObject("ADODB.Recordset")
    
    		' solo se esiste type
    		if ( Request.QueryString("type") <> "" AND Request.QueryString("tip") = "" AND Request.QueryString("brand") = "" ) then
    			brandRS.open ("SELECT DISTINCT modello, ma, tp, desc, desc_e, stato,prezzo_vendita_usa FROM articoli WHERE type=" & Request.QueryString("type") & " ORDER BY stato DESC") ,connessione
    		' esiste type e tip
    		elseif (Request.QueryString("type") <> "" AND Request.QueryString("tip") <> "" AND Request.QueryString("brand") = "") then
    			brandRS.open ("SELECT DISTINCT modello, ma, tp, desc, desc_e, stato,prezzo_vendita_usa FROM articoli WHERE tp=""" & Request.QueryString("tip") & """ AND type=" & Request.QueryString("type") & " ORDER BY stato DESC") ,connessione
    		' esiste type, tip brand e lin , quindi full
    		else
    			brandRS.open ("SELECT DISTINCT modello, ma, tp, desc, desc_e, stato,prezzo_vendita_usa FROM articoli WHERE ma=""" & Request.QueryString("brand") & """ AND tp=""" & Request.QueryString("tip") & """ AND type=" & Request.QueryString("type") & " ORDER BY stato DESC" ) ,connessione
    		end if
    		
    
    		'-------------------------------------------
    		'   PAGINAZIONE RECORDSET
    		'-------------------------------------------
    		
    		record_x_pagina = 4
    		num_tot_record = 0
    		record_da = 0
    		record_a = 0
    		
    		
    		while not brandRS.eof
    			num_tot_record = num_tot_record + 1
    			brandRS.movenext
    		wend
    		
    		
    		if request.querystring("pagina")="" then
    			pagina = 1
    		else
    			pagina=cint(request.querystring("pagina"))
    		end if
    		
    		num_tot_pagine=round(num_tot_record/record_x_pagina + 0.5)
    		
    		record_da = (pagina-1)*record_x_pagina +1
    		record_a = record_x_pagina*pagina
    
    		'--------------------------------
    		'     FINE PAGINAZIONE
    		'--------------------------------		
    		
    		' resetto all'inizio il RS
    		brandRS.movefirst
    		
    		' sposto in avanti il rs start
    		for z=1 to record_da-1
    			brandRS.movenext
    		next
    		
    		k = 1
    questo è l'inclide che scrive a video la paginazione (il numero delel pagine insomma)
    codice:
    <div id="pagination">
      <% if num_tot_pagine > 1 then 
    str = replace(Request.QueryString(),"pagina=" & Request("pagina") & "&","")
    %>
    <%if pagina > 3 and num_tot_pagine > 3 then%>
    <% if pagina > 3 and num_tot_pagine > 3 then%>
    First
    <%end if%>
    <%end if%>
    <% 	for s = pagina-2 to pagina-1
    if s > 0 then%><%=s%><%end if
    			next
    		%><span class="showed"><%=pagina%></span>
            <%	for s = pagina+1 to pagina+2
    				if s<= num_tot_pagine then%><%=s%><%end if
    			next
    if pagina +2 < num_tot_pagine and num_tot_pagine>3 then%>Last
    <% end if 
    if pagina +2 < num_tot_pagine then
    end if
    Set str = Nothing
    end if %>
    </div>

    A video per stampare i rpodotti uso questo ciclo
    codice:
    while (not brandRS.eof) AND (k <= record_x_pagina)  ' e lo faccio finire a fine della pagina
    
    
    
    [....]
    
    				k= k + 1 ' incremento il contatore del record
    				if k MOD 2 = 1 then Response.Write("</tr><tr>")	end if ' vado a capo con la tabella
    				brandRS.movenext
    			wend
    If what you were looking for doesn't show up, investigate it!
    Google is your friend

  2. #2
    up :/
    If what you were looking for doesn't show up, investigate it!
    Google is your friend

  3. #3
    Che database usi?
    Se usi un DB Access o SQL Server puoi benissimo sfruttare le proprietà di ADO ed usare .PageSize e .AbsolutePage per farti restituire un recordset corrispondente alla pagina in cui devi trovarti.

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.