Visualizzazione dei risultati da 1 a 10 su 10
  1. #1
    Utente di HTML.it L'avatar di mrzpro
    Registrato dal
    Mar 2008
    Messaggi
    36

    Array con link cliccabili

    Ciao a tutti, cerco di spiegare il mio problema:
    stò cercando di creare un dizionario ed ho un database da cui estraggo le parole in Italiano ed in Inglese popolando un array. La lista viene fatta cliccando sulla lettera iniziale ad es. "A" e mi vengono riportate tutte le parole che iniziano per "A" rese, con <a href..., cliccabili. Clickando su una parola, con javascript, compare o scompare la relativa traduzione.Il mio problema è che la traduzione che compare è sempre relativa alla prima parola e non si aggiorna quando ne scelgo un' altra. Ho verificato leggendo l' HTML della pagina generata, che tutte le opzioni richieste sono generate correttamente ma la traduzione ottenuta, su qualsiasi parola clicco è sempre quella della prima parola.
    ....avete idea di come posso risolvere il problema?
    grazie a tutti

  2. #2
    ciao.

    usi MySQL? se si, un query si fà!

    per esempio:

    Codice PHP:
    <?php
    // DB informazione
    mysql_connect("localhost","USER","PASS");
    mysql_select_db("DATABASE");

    // se non si definire poi usi "A"
    if(!isset($_GET['pagina'])){
      
    $_GET['pagina'] = "A";
    }

    // il query - tutte le parole che si iniziare con la lettera
    $query mysql_query("SELECT * FROM DATABASE_NOME WHERE parole_nome LIKE '".strtoupper($_GET['pagina'])."%'");

    // print l'informazione
    while($row mysql_fetch_array($query)){
      print 
    "<a href=\"?vista=".$row[id]."\">".$row[nome]."</a>";
    }

    ?>
    adesso ?vista=$row[id] non è nel questo script. cmq questa è la basica idea.

    anche non so la struttura del tuo database cosi alcuni dei variabili forse non fà.

    Ciao,
    Dennis
    Nuovo Blog di Programmazione! (Lo ha i tutti tipi! PHP e C/C++)
    Per piacere lo supporti!

  3. #3
    Utente di HTML.it L'avatar di mrzpro
    Registrato dal
    Mar 2008
    Messaggi
    36
    Dear Dennis, I'll try to use the routine you give me but take into account that I' ll have a list of words and each one of this must be clickable to show the right translation for example in the same page I have:

    a
    aa
    ab
    ac
    ad
    ae

    always in the same page I must have the possibility to click the word aa and after that the word ac or ad or whatever but at this moment my script give me always the meaning of the first word. Sorry if it's not clear but it depends on my english..
    Thank you very much

  4. #4
    Utente di HTML.it L'avatar di mrzpro
    Registrato dal
    Mar 2008
    Messaggi
    36
    Sorry Dennis I use PhP and mySQL the structure of my Database is:

    database name "dict"
    table name "words"
    fields name "id, FER,ITA,ENG"

    I've to list on the field FER and clicking on the listed words I've to obtain the meanings of FER contained in ITA and ENG....

    FER is the language of my town "Ferentino"
    ITA for italian
    ENG for english

    hoping that's clear.....
    Many many Thx

  5. #5
    Can we speak English here? I can if it is easier for you to understand me (as you can see I am American XD)

    We'll do this like this: YOURSITE.com/pagina1.php?lang=it&let=a
    (lang options are it,en,fer).

    That URL (with this script) will give you ALL words beginning with the Letter "A" in the Italian Language that are in the database.

    pagina1.php
    Codice PHP:
    <?php
    /**
     * Script da Dennis M.
     *
     */

    // l'informazione del database
    $db mysql_connect("localhost","USER","PASS");
    mysql_select_db("dict");

    // se non si definire poi usi la lingua italiana e la lettera "a"
    if(!isset($_GET['lang']) OR strtolower($_GET['lang']) != "en" AND strtolower($_GET['lang']) != "fer"){
      
    $_GET['lang'] = "it";
    }
    if(!isset(
    $_GET['let'])){
      
    $_GET['let'] = "a";
    }

    // per processare i variabili
    if($_GET['lang'] == "it"){
      
    $query mysql_query("SELECT * FROM words WHERE ITA LIKE '".mysql_escape_string($_GET['let'])."%' ORDER BY ITA ASC");
      print 
    "Tutte le parole si iniziando con \"".strtoupper($_GET['let'])."\":

    "
    ;
      
    $messaggio "<a href=\"pagina2.php?lang=".$_GET['lang']."&parola=".stripslashes($row['ITA'])."\">".stripslashes($row['ITA'])."</a>
    "
    ;
    } else if(
    $_GET['lang'] == "en"){
      
    $query mysql_query("SELECT * FROM words WHERE ENG LIKE '".mysql_escape_string($_GET['let'])."%' ORDER BY ENG ASC");
      print 
    "All words beginning with \"".strtoupper($_GET['let'])."\":

    "
    ;
      
    $messaggio "<a href=\"pagina2.php?lang=".$_GET['lang']."&parola=".stripslashes($row['ENG'])."\">".stripslashes($row['ENG'])."</a>
    "
    ;
    } else {
      
    $query mysql_query("SELECT * FROM words WHERE FER LIKE '".mysql_escape_string($_GET['let'])."%' ORDER BY FER ASC");
      print 
    "Tutte le parole si inizando con \"".strtoupper($_GET['let'])."\": (nel ferentino)

    "
    ;
      
    $messaggio "<a href=\"pagina2.php?lang=".$_GET['lang']."&parola=".stripslashes($row['ENG'])."\">".stripslashes($row['FER'])."</a>
    "
    ;
    }

    // Adesso monstriamo a tutto
    while($row mysql_fetch_array($query)){
      if(
    $_GET['lang'] == "it"){
        print 
    "<a href=\"pagina2.php?lang=".$_GET['lang']."&parola=".stripslashes($row['ITA'])."\">".stripslashes($row['ITA'])."</a>
    "
    ;
      } else if(
    $_GET['lang'] == "en"){
        print 
    "<a href=\"pagina2.php?lang=".$_GET['lang']."&parola=".stripslashes($row['ENG'])."\">".stripslashes($row['ENG'])."</a>
    "
    ;
      } else {
        print 
    "<a href=\"pagina2.php?lang=".$_GET['lang']."&parola=".stripslashes($row['ENG'])."\">".stripslashes($row['FER'])."</a>
    "
    ;
      }
    }

    // finito :)
    mysql_close($db);
    ?>
    That processes all the informazione. Now, to see the translations, we're going to use a second page:

    pagina2.php
    Codice PHP:
    <?php
    /**
     * Script da Dennis M.
     *
     */

    // l'informazione del database
    $db mysql_connect("localhost","USER","PASS");
    mysql_select_db("dict");

    // ancora deviamo si processare
    if(!isset($_GET['lang']) OR $_GET['lang'] != "en" AND $_GET['lang'] != "fer"){
      
    $_GET['lang'] = "it";
    }

    // per processare i variabili
    if($_GET['lang'] == "it"){
      
    $query mysql_query("SELECT * FROM words WHERE ITA='".mysql_escape_string($_GET['parola'])."'");
      
    $noparola "La parola non esista.";
    } else if(
    $_GET['lang'] == "en"){
      
    $query mysql_query("SELECT * FROM words WHERE ENG='".mysql_escape_string($_GET['parola'])."'");
      
    $noparola "The word does no exist.";
    } else {
      
    $query mysql_query("SELECT * FROM words WHERE FER='".mysql_escape_string($_GET['parola'])."'");
      
    $noparola "La parola non esista. (nel ferentino)";
    }

    // i errori
    if(!isset($_GET['parola'])){
      print 
    $noparola;
      exit;
    }
    if(
    mysql_num_rows($query) == 0){
      print 
    $noparola;
      exit;
    }

    // possiamo si guardare la pagina adesso :)
    while($row mysql_fetch_array($query)){
      print 
    "\"".$_GET['parola']."\" [i](".strtoupper($_GET['lang']).")[/i]<hr>";
      if(
    $_GET['lang'] != "it"){
        print 
    "[b]Italiano:[/b] ".stripslashes($row['ITA'])."
    "
    ;
      }
      if(
    $_GET['lang'] != "en"){
        print 
    "[b]English:[/b] ".stripslashes($row['ENG'])."
    "
    ;
      }
      if(
    $_GET['lang'] != "fer"){
        print 
    "[b]Ferentino:[/b] ".stripslashes($row['FER'])."
    "
    ;
      }
    }

    // Finito :)
    mysql_close($db);
    ?>
    cioè che hai un bisogno?

    Ciao,
    Dennis
    Nuovo Blog di Programmazione! (Lo ha i tutti tipi! PHP e C/C++)
    Per piacere lo supporti!

  6. #6
    Utente di HTML.it L'avatar di mrzpro
    Registrato dal
    Mar 2008
    Messaggi
    36
    Thank you very much Danny, I'll try immediately your hints and I'll be back to give an answer asap...
    looking forward
    Maurizio

  7. #7
    Utente di HTML.it L'avatar di mrzpro
    Registrato dal
    Mar 2008
    Messaggi
    36
    Hi Dennis, it works greatly.....Thank you very much...
    another little request: from your great experience, or if you'd know, it's possible to obtain it in one web page only ?

    Thank you again
    Maurizio

  8. #8
    si si c'è un modo.

    Codice PHP:
    <?php
    /**
    * Script da Dennis M.
    *
    */

    // l'informazione del database
    $db mysql_connect("localhost","USER","PASS");
    mysql_select_db("dict");

    // se non si definire poi usi la lingua italiana e la lettera "a"
    if(!isset($_GET['lang']) OR strtolower($_GET['lang']) != "en" AND strtolower($_GET['lang']) != "fer"){
      
    $_GET['lang'] = "it";
    }
    if(!isset(
    $_GET['let'])){
      
    $_GET['let'] = "a";
    }

    // se nessun parola si definire
    if(!isset($_GET['parola'])){
      
    // per processare i variabili
      
    if($_GET['lang'] == "it"){
        
    $query mysql_query("SELECT * FROM words WHERE ITA LIKE '".mysql_escape_string($_GET['let'])."%' ORDER BY ITA ASC");
        print 
    "Tutte le parole si iniziando con \"".strtoupper($_GET['let'])."\":

    "
    ;
        
    $messaggio "<a href=\"?lang=".$_GET['lang']."&parola=".stripslashes($row['ITA'])."\">".stripslashes($row['ITA'])."</a>
    "
    ;
      } else if(
    $_GET['lang'] == "en"){
        
    $query mysql_query("SELECT * FROM words WHERE ENG LIKE '".mysql_escape_string($_GET['let'])."%' ORDER BY ENG ASC");
        print 
    "All words beginning with \"".strtoupper($_GET['let'])."\":

    "
    ;
        
    $messaggio "<a href=\"?lang=".$_GET['lang']."&parola=".stripslashes($row['ENG'])."\">".stripslashes($row['ENG'])."</a>
    "
    ;
      } else {
        
    $query mysql_query("SELECT * FROM words WHERE FER LIKE '".mysql_escape_string($_GET['let'])."%' ORDER BY FER ASC");
        print 
    "Tutte le parole si inizando con \"".strtoupper($_GET['let'])."\": (nel ferentino)

    "
    ;
        
    $messaggio "<a href=\"?lang=".$_GET['lang']."&parola=".stripslashes($row['FER'])."\">".stripslashes($row['FER'])."</a>
    "
    ;
      }

      
    // Adesso monstriamo a tutto
      
    while($row mysql_fetch_array($query)){
        if(
    $_GET['lang'] == "it"){
          print 
    "<a href=\"?lang=".$_GET['lang']."&parola=".stripslashes($row['ITA'])."\">".stripslashes($row['ITA'])."</a>
    "
    ;
        } else if(
    $_GET['lang'] == "en"){
          print 
    "<a href=\"?lang=".$_GET['lang']."&parola=".stripslashes($row['ENG'])."\">".stripslashes($row['ENG'])."</a>
    "
    ;
        } else {
          print 
    "<a href=\"?lang=".$_GET['lang']."&parola=".stripslashes($row['ENG'])."\">".stripslashes($row['FER'])."</a>
    "
    ;
        }
      }
    } else {
      
    /**
      * PAGINA2.php ecco
      *
      */
      // ancora deviamo si processare
      
    if(!isset($_GET['lang']) OR $_GET['lang'] != "en" AND $_GET['lang'] != "fer"){
        
    $_GET['lang'] = "it";
      }

      
    // per processare i variabili
      
    if($_GET['lang'] == "it"){
        
    $query mysql_query("SELECT * FROM words WHERE ITA='".mysql_escape_string($_GET['parola'])."'");
        
    $noparola "La parola non esista.";
      } else if(
    $_GET['lang'] == "en"){
        
    $query mysql_query("SELECT * FROM words WHERE ENG='".mysql_escape_string($_GET['parola'])."'");
        
    $noparola "The word does no exist.";
      } else {
        
    $query mysql_query("SELECT * FROM words WHERE FER='".mysql_escape_string($_GET['parola'])."'");
        
    $noparola "La parola non esista. (nel ferentino)";
      }

      
    // i errori
      
    if(!isset($_GET['parola'])){
        print 
    $noparola;
        exit;
      }
      if(
    mysql_num_rows($query) == 0){
        print 
    $noparola;
        exit;
      }

      
    // possiamo si guardare la pagina adesso [img]images/smilies/smile.gif[/img]
      
    while($row mysql_fetch_array($query)){
        print 
    "\"".$_GET['parola']."\" [i](".strtoupper($_GET['lang']).")[/i]<hr>";
        if(
    $_GET['lang'] != "it"){
          print 
    "[b]Italiano:[/b] ".stripslashes($row['ITA'])."
    "
    ;
        }
        if(
    $_GET['lang'] != "en"){
          print 
    "[b]English:[/b] ".stripslashes($row['ENG'])."
    "
    ;
        }
        if(
    $_GET['lang'] != "fer"){
          print 
    "[b]Ferentino:[/b] ".stripslashes($row['FER'])."
    "
    ;
        }
      }
    }
    // finito [img]images/smilies/smile.gif[/img]
    mysql_close($db);
    ?>
    il questo script fà per che hai un bisogno!

    Ciao,
    Dennis
    Nuovo Blog di Programmazione! (Lo ha i tutti tipi! PHP e C/C++)
    Per piacere lo supporti!

  9. #9
    Utente di HTML.it L'avatar di mrzpro
    Registrato dal
    Mar 2008
    Messaggi
    36
    Dear Dennis, due to my poor english maybe I've not been too much clear what I need to realize is something like this (follow the link)

    http://www.dizionariogenovese.com/tr...iano-genovese/

    In your opinion is it realizable? Or I've to use other languages?

    Due to the fact that I'm trying to realize it for my site (www.ferentino.org) please send me your address to write it in the "credits" of it, in this section I' ve inserted all the persons that for a reason or another have given me a help...
    looking forwaed
    Maurizio

  10. #10
    vogli su un pagina come il sito mi hai inviato? è possibile comunque bisogna usare il javascript (beh AJAX) posso capire l'italiano più meglio di scrivo :P cosi se è più facile a parlare l'italiano poi si puoi.

    mio l'indirizzo: dennis.mcwherter@gmail.com

    Ciao,
    Dennis
    Nuovo Blog di Programmazione! (Lo ha i tutti tipi! PHP e C/C++)
    Per piacere lo supporti!

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.