Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Nov 2006
    Messaggi
    253

    Problemi con paginazione db MySSQL

    Salve a tutti,

    servendomi di questo articolo

    http://database.html.it/articoli/leg...l-tramite-asp/

    ho tentato di realizzare una paginazione dei record con db my sql.

    L'unica differenza è che l'articolo esegue una query diretta, mentre io la eseguo a partire da alcuni query string che passo da una pagina precedente avente la funzione di pagina di ricerca. Di seguito posto il codice da me utilizzato.

    <----------------------------TUTTI I QUERYSTRING EFFETTUATI----------------------->

    Dim CognPlayer,OwnPlayer,RealTeam,Position
    CognPlayer = Request.QueryString ("CognPlayer")
    OwnTeam = CInt(Request.QueryString ("Team"))
    RealTeam = CInt(Request.QueryString ("RealTeam"))
    Position = Cint(Request.QueryString ("Position"))

    Dim control1,control2,control3,control4

    control1 = Request.QueryString ("Ctrl1")
    control2 = Request.QueryString ("Ctrl2")
    control3 = Request.QueryString ("Ctrl3")
    control4 = Request.QueryString ("Ctrl4")

    <--------------------------TUTTE LE STRINGHE PER LA SELECT FINALE----------------->
    Dim strSelect, strWhere, strOper,strOrderBy

    strSelect = "select * from players"
    strWhere = ""
    strOper=""
    strOrderBy=" "&"order by players.fk_real_team_id"


    Mi fermo qui perchè il codice è troppo lungo...posto il resto in 1 nuovo messaggio

  2. #2
    Utente di HTML.it
    Registrato dal
    Nov 2006
    Messaggi
    253
    Ecco la seconda parte

    <-------COSTRUZIONE DELLE SELECT IN BASE AI PARAMETRI DI RICERCA INSERITI---->

    if CognPlayer <> "" then
    strWhere = " where players.player_sec_name like '%"&CognPlayer&"%' "
    strOper = control1
    end if

    if RealTeam <> 0 then
    if strWhere = "" then
    strWhere = " where players.fk_real_team_id = "&RealTeam&" "
    strOper = control2
    else
    strWhere = strWhere & strOper & " players.fk_real_team_id = "&RealTeam&" "
    strOper = control2
    end if
    end if

    if OwnTeam <> 0 then
    if strWhere = "" then
    strSelect = "select * from players_allowed_teams"
    strWhere = " where players_allowed_teams.fk_team_id = "&OwnTeam&" "
    strOper = control3
    else
    strSelect = strSelect & " inner join players_allowed_teams on player_id= fk_player_id"
    strWhere = strWhere & strOper & " players_allowed_teams.fk_team_id = "&OwnTeam&" "
    strOper = control3
    end if
    end if

    if Position <> 0 then
    if strWhere = "" then
    strWhere = " where players.fk_player_position_id = "&Position&" "
    else
    strWhere = strWhere & strOper & " players.fk_player_position_id = "&Position&" "
    strOper = control4
    end if
    end if

    <----------------------------COSTRUISCO LA PAGINAZIONE------------------------->

    page = Cint(Request.QueryString("page"))
    strSelectCount = "select count(player_id) as Conteggio from players"
    set Rs_ContaPlayers = Conn.Execute (strSelectCount & strWhere)

    if page = 0 then
    page = 1

    dim tot_record,pageSize,inizio,pagine_totali, strSQLLimit

    tot_record = Rs_ContaPlayers(0)
    set Rs_ContaPlayers = nothing

    'Record per pagina
    pageSize = 5

    'Primo record di ogni pagina
    inizio = (Cint(page-1) * CInt(pageSize))

    'Pagine complessive per effetto della paginazione
    pagine_totali = CInt(tot_record) / CInt(pageSize)

    'Arrotondamento in caso di resto della divisione precedente
    if pagine_totali - CInt(pagine_totali) > 0 then
    pagine_totali = CInt(pagine_totali + 1)
    else
    pagine_totali = CInt(pagine_totali)
    end if

    'Visualizzazione dei record paginati
    strLimit = " LIMIT "&inizio&","&pageSize
    set Rs_Players = Conn.Execute (strSelect & strWhere & strOrderBy & strLimit)

    <---------------------------------------------------------------------------------->

    Subito dopo inizia la parte di interfaccia, se volete posto anche quella.
    Il problema che ho è che dopo che mi ha visualizzato i primi 5 record al primo caricamento, quando clicco su VAI ALLA PAG SUCCESSIVA mi ritorna una pagina bianca.
    Qualcuno sa cosa sbaglio?

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 © 2026 vBulletin Solutions, Inc. All rights reserved.