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

    Problemi con paginazione Asp & MySQL

    Ciao al forum.

    Problema di paginazione in MySQL: mentre il link pagina precedente funziona bene, il link pagina successiva si visualizza sempre anche quando non ho più records da estrarre.

    Cosa sbaglio?

    codice:
    <%
       count = 0
       pageSize = 25
       
       if(len(Request.QueryString("pagina"))=0)then
          currentPage = 1
       else
          currentPage = CInt(Request.QueryString("pagina"))
       end if
    
       If Not IsNumeric (currentPage) Then currentpage = 1
       If currentPage < 1 Then currentPage = 1
    
       start = ((currentPage - 1) * pageSize)
       If start < 0 Then start = 0
    %>
    
    <% SQL = "..... %>
    
    <% if currentPage > 1 then %>
    Pag precedente 
    <% else %>
    Pag precedente<% end if %>
    | 
    <% if cInt(start) <> cInt(pageSize) then %>
    Pag successiva
    <% else %>
    Pag successiva
    <% end if %>
    Gracias!

  2. #2

    Re: Problemi con paginazione Asp & MySQL

    codice:
    <%
       pageSize = 25
       
       if(len(Request.QueryString("pagina"))=0)then
          currentPage = 1
       else
          currentPage = CInt(Request.QueryString("pagina"))
       end if
    
       If Not IsNumeric (currentPage) Then currentpage = 1
       If currentPage < 1 Then currentPage = 1
    
       start = ((currentPage - 1) * pageSize)
       If start < 0 Then start = 0
    %>
    
    <% SQL = "SELECT * FROM tabella LIMIT " & start & ", " & pageSize %>
    <% Set RS = Server.CreateObject("ADODB.Recordset") %>
    <% RS.Open SQL, cn %>
    
    <% if Not RS.eof then %>
    <% while not RS.eof %>
    
    <% RS.movenext() %>
    <% wend %>
    <% end if %>
    <% RS.Close() : Set RS = Nothing %>
    
    <% if currentPage > 1 then %>
    Pag precedente 
    <% else %>
    Pag precedente<% end if %>
    | 
    <% if cInt(start) <> cInt(pageSize) then %>
    Pag successiva
    <% else %>
    Pag successiva
    <% end if %>

  3. #3
    Utente di HTML.it L'avatar di ubbicom
    Registrato dal
    Mar 2004
    Messaggi
    1,407
    Ho provato e così funziona.
    Ho usato le funzioni di MySQL (davvero potente...) .


    codice:
    <%
       pageSize = 5
       
       if(len(Request.QueryString("page"))=0)then
          currentPage = 1
       else
          currentPage = CInt(Request.QueryString("page"))
       end if
    
       If Not IsNumeric (currentPage) Then currentpage = 1
       If currentPage < 1 Then currentPage = 1
    
       start = ((currentPage - 1) * pageSize)
       If start < 0 Then start = 0
    %>
    
    <% SQL = "SELECT SQL_CALC_FOUND_ROWS * FROM tabella LIMIT " & start & ", " & pageSize %>
    <% Set RS = Server.CreateObject("ADODB.Recordset") %>
    
    <% RS.Open SQL, objConn %>
    <% if Not RS.eof then %>
    
    <% SQL1 = "SELECT FOUND_ROWS() AS rC;" %>
    <% Set RS1 = objConn.Execute(SQL1) %>
    <% recordCount = RS1("rC") %>
    <% Set RS1 = Nothing %>
    
    <% while not RS.eof %>
    
    <% response.write RS("TITOLO") & "
    " %>
    
    <% RS.movenext() %>
    <% wend %>
    
    <% end if %>
    <% RS.Close() : Set RS = Nothing %>
    
    <% if currentPage > 1 then %>
    Prev 
    <% else %>
    Prev<% end if %>
    | 
    <% if cInt(start+pageSize) < cInt(recordCount) then %>
    Next
    <% else %>
    Next
    <% end if %>

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.