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

    [JQuery+PHP]Autocompleter

    Ciao Ragazzi ho un problema con l'autocomplete di jQuery praticamente io ricevo i termini da PHP, eseguo a query composta da union di più select ma il completamento me lo esegue solo dai risultati che escono dalla select di una di loro,le altre le ignora proprio....
    Però se io vedo cosa esce,l'array jSon è perfetto ovvero: [{"id":"100","value":"usernameUser"}]
    ma non me lo visualizza...

    Dove pensate sia il problema?

  2. #2
    Lo script è questo:

    Codice PHP:
    <?php
    $queryStringAll 
    'SELECT id,username FROM
    (

        (
            SELECT DISTINCT 1 AS RIFERIMENTO, utenti.id , utenti.username 
            FROM _pm_Invitati INNER JOIN utenti ON utenti.id = _pm_Invitati.User_ID 
            WHERE utenti.username LIKE \''
    .$q.'%\' AND _pm_Invitati.PM_ID = '.$idC.'
            )
       
     UNION ALL
         (
            SELECT DISTINCT 2 AS RIFERIMENTO, id, username
            FROM
            (
              SELECT amicizie.from_friend AS id, utenti.username
              FROM amicizie
              INNER JOIN utenti ON
              amicizie.from_friend = utenti.id
              WHERE ((utenti.username LIKE \''
    .$q.'%\' )AND(to_friend = '.$id_utente.')) 
              UNION
              SELECT amicizie.to_friend AS id, utenti.username
              FROM amicizie
              INNER JOIN utenti ON
              amicizie.to_friend = utenti.id
              WHERE ((utenti.username LIKE \''
    .$q.'%\' )AND(from_friend = '.$id_utente.'))
            ) AS MyQuery
            WHERE id NOT IN
            (
                SELECT User_ID
                FROM _pm_Invitati
                WHERE PM_ID = '
    .$idC.'
                UNION
                SELECT User_ID
                FROM _pm_Espulsi
                WHERE PM_ID = '
    .$idC.'
            )
        )
     UNION ALL
         (
          SELECT DISTINCT 3 AS RIFERIMENTO, utenti.id, utenti.username
          FROM _pm_Espulsi INNER JOIN utenti ON utenti.id = _pm_Espulsi.User_ID WHERE  utenti.username LIKE \''
    .$q.'%\' AND _pm_Espulsi.PM_ID = '.$idC.' AND _pm_Espulsi.Volonta IN(1,2)
        )
     UNION ALL
         (
           SELECT  DISTINCT 4 AS RIFERIMENTO, utenti.id, utenti.username
          FROM _pm_Espulsi INNER JOIN utenti ON utenti.id = _pm_Espulsi.User_ID WHERE utenti.username LIKE \''
    .$q.'%\' AND _pm_Espulsi.PM_ID = '.$idC.' AND _pm_Espulsi.Volonta = 0
          )
    )AS TUTTI ORDER BY username'
    ;

        
    $queryUSR mysql_query("$queryStringAll")or die("Query failed with error: ".mysql_error());
                                 
        
    $Existing_SK mysql_affected_rows();
        while (
    $query_res mysql_fetch_array($queryUSR))
        { 
    // apertura while iniziale

            
    $row_array['id'] = $query_res['id'];
            
    $row_array['value'] = $query_res['username'];

            
    array_push($return_arr,$row_array);
                
        }
            
    echo 
    json_encode($return_arr);

    ?>

  3. #3
    Ho anche provato solo con la prima query ma non mi estrae niente eppure se apro direttamente il file mi visualizza l'array json in modo giusto e se eseguo la query su db funziona correttamente..

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.