Visualizzazione dei risultati da 1 a 10 su 10

Discussione: dividere in pagine!

  1. #1
    Utente di HTML.it
    Registrato dal
    Oct 2008
    Messaggi
    26

    dividere in pagine!

    io in ASP ho un database dal quale voglio estrarre delle informazioni, però vorrei che queste informazioni escano 10 per pagina, come posso fare???

  2. #2

  3. #3
    Utente di HTML.it
    Registrato dal
    Oct 2008
    Messaggi
    26
    si access

  4. #4
    Utente di HTML.it
    Registrato dal
    Oct 2008
    Messaggi
    26
    io voglio tipo che i primi 10 risultati siano nella prima pagina i successivi 10 nella seconda...e così via... non so se intendo...

  5. #5
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Ti ho già risposto...

    Roby

  6. #6
    Utente di HTML.it L'avatar di Mizushi
    Registrato dal
    Aug 2005
    Messaggi
    1,125
    Paginazione mdb ( credits Imente )

    codice:
    <%
    option explicit
    
    function excess(argValue)
    	if not (int(argValue) = argValue) then argValue = int(argValue)+1	
    	excess = argValue
    end function
    
    
    function cleanLong(argValue)
    	on error resume next
    	if argValue = "" then : cleanLong = clng(0) : else : cleanLong = clng(trim(argValue)) : end if
    	if err.number <> 0 then cleanLong = 0
    	on error goto 0
    end function
    
    dim conn, rs, SQL, SQLwhere
    Set conn = Server.CreateObject("ADODB.Connection")
    set rs = Server.CreateObject("ADODB.Recordset")
    Conn.Open "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = " & server.mappath("database.mdb") & " ; Persist Security Info = False"
    
    dim wbp_recordPerPage, wbp_totalRecords, wbp_totalPages, wbp_currentRecord, wbp_currentPage, wbp_lastcurrentRecord
    dim wbp_isEmpty
    dim wbp_baseQuerystring, wbp_basePage
    dim argPage
    
    '*** EDIT *** impostare quanti record in ogni pagina
    wbp_recordPerPage = 3
    
    argPage = cleanLong(request.QueryString("page"))
    if argPage < 1 then argPage = 1
    
    '* 1. selezionare SOLO gli id
    '* 2. applicare in questa query gli eventuali filtri di selezione
    SQL = "SELECT id FROM tabella"
    rs.open SQL, Conn, 3, 3
    
    '* impostazione variabili di navigazione (pagine)
    wbp_totalRecords = cint(rs.recordcount)
    wbp_totalPages = excess(wbp_totalRecords / wbp_recordPerPage)
    wbp_currentRecord = ((argPage - 1) * wbp_recordPerPage) + 1
    if wbp_currentRecord > wbp_totalRecords then
    	wbp_currentPage = 1
    	wbp_currentRecord = ((wbp_currentPage - 1) * wbp_recordPerPage) + 1
    else
    	wbp_currentPage = argPage
    end if
    wbp_lastcurrentRecord = wbp_currentRecord + wbp_recordPerPage - 1
    if wbp_lastcurrentRecord > wbp_totalRecords then wbp_lastcurrentRecord = wbp_totalRecords
    
    SQLwhere = ""
    
    wbp_isEmpty = true
    
    if not rs.eof then
    	'* spostamento nel recordset
    	rs.pagesize = wbp_recordPerPage
    	rs.absolutepage = wbp_currentPage
    
    	wbp_isEmpty = false
    	
    	'* creazione seconda query (recordset completo, solo per gli ID selezionati nella prima query)
    	dim ii
    	for ii=0 to wbp_recordPerPage-1
    		'*** EDIT *** al posto di ID mettere il nome del campo ID della vostra tabella
    		SQLwhere = SQLwhere & " or id = " & rs("id") & ""
    		rs.movenext
    		if rs.eof then exit for
    	next
    	set ii = nothing
    	rs.close
    	SQLwhere = right(SQLwhere,len(SQLwhere)-3)
    end if
    
    if not wbp_isEmpty then
    
    	'*** EDIT *** selezionare TUTTI i campi necessari
    	SQL = "SELECT id, campo FROM tabella WHERE " & SQLwhere & " ORDER BY id ASC"
    
    	set rs = conn.execute(SQL)
    	while not rs.eof
    		'*** EDIT *** STAMPA DEL RECORDSET (da personalizzare secondo le esigenze)
    		response.write rs("campo") & "
    "
    		rs.movenext
    	wend
    	%>
    	<div class="page_navigator">
    	<span class="page_view"><%
    	
    		'*** EDIT *** pagina a cui puntare
    		wbp_basePage = "pag.asp"
    		'*** EDIT *** querystring aggiuntiva ( es: "&sort=date" )
    		wbp_baseQuerystring = ""
    		
    		%></span>
    <span class="topic-pages"><%
    		if wbp_totalPages > 1 then
    			%><span class="page_pagesnav"><%=wbp_totalPages%> pagine [ <%
    			if wbp_currentPage > 1 then
    				if wbp_currentPage > 2 then
    					%>&lt;&lt; <%
    				end if
    			%>&lt; <%
    				if wbp_currentPage - 3 > 0 then%><%=wbp_currentPage-3%> <% end if
    				if wbp_currentPage - 2 > 0 then%><%=wbp_currentPage-2%> <% end if
    				if wbp_currentPage - 1 > 0 then%><%=wbp_currentPage-1%> <% end if
    			end if
    			%><%=wbp_currentPage%> <%
    			if wbp_currentPage < wbp_totalPages then
    				if wbp_currentPage + 1 < wbp_totalPages + 1 then%><%=wbp_currentPage+1%> <% end if
    				if wbp_currentPage + 2 < wbp_totalPages + 1 then%><%=wbp_currentPage+2%> <% end if
    				if wbp_currentPage + 3 < wbp_totalPages + 1 then%><%=wbp_currentPage+3%> <% end if
    				%>&gt; <%
    				if wbp_currentPage < wbp_totalPages - 1 then
    					%>&gt;&gt; <% 
    				end if
    			end if
    		%> ]</span><%
    		else
    		%>1 pagina<%
    		end if%>
    	</span>
    	</div><%
    	
    else
    	'*** EDIT *** se il recordset è vuoto...
    	response.write "nessun record"
    	
    end if
    
    
    %>

  7. #7
    Utente di HTML.it
    Registrato dal
    Oct 2008
    Messaggi
    26
    e così visualizzo le informazioni dall ID 1 all'ID 10 e se le mie informazioni le voglio visualizzare in ordine alfabetico..???

  8. #8
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    codice:
    SQL = "SELECT id, campo FROM tabella WHERE " & SQLwhere & " ORDER BY NOME ASC"
    Roby

  9. #9
    Utente di HTML.it L'avatar di Mizushi
    Registrato dal
    Aug 2005
    Messaggi
    1,125
    Originariamente inviato da kloo89
    e così visualizzo le informazioni dall ID 1 all'ID 10 e se le mie informazioni le voglio visualizzare in ordine alfabetico..???


    codice:
    SQL = "SELECT id, campo FROM tabella WHERE " & SQLwhere & " ORDER BY id ASC"

    Al posto di ORDER BY id ASC metti ORDER BY tuocampochecontieneinfo ASC

  10. #10
    Utente di HTML.it
    Registrato dal
    Dec 2005
    Messaggi
    69

    Re: dividere in pagine!

    Originariamente inviato da kloo89
    io in ASP ho un database dal quale voglio estrarre delle informazioni, però vorrei che queste informazioni escano 10 per pagina, come posso fare???
    Ciao ti posto il link che ti può aiutare http://forum.html.it/forum/showthrea...eadid=1291537.

    ::CIRMAS::
    http://www.lottointelligente.it
    (il gioco del lotto, previsioni lotto gratis, forum lotto, spazio personale utenti)
    http://www.commerciobresciano.it (portale annunci)

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.