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

    prelevare dati da mysql

    ciao a tutti, ieri sera sono finalmente riuscita a caricare tramite LoadVars() il nome di un utente dal mio database. Pero' de volevo prelevare anche il cognome dello stesso utente, non me lo visualizzava, come mai? vi posto i codici.
    nel filmato carica.fla ho 2 campi di testo input con variabile "nome" e "cognome", sul fotogramma ho questo codice:
    codice:
    dati = new LoadVars(); //creo una variabile
    dati.load("recuperoDB.php"); //associo la variabile al file dinamico php
    dati.onLoad = function() {
    	nome = this.immagine; 
    		
    	
    };
    nel file recuperoDB.php ho questo codice:
    codice:
    <?php
    // set your infomation.
    
    $dbhost='localhost';
    
    $dbusername='root';
    
    $dbuserpass='';
    
    $dbname='mamma';
    
    // connect to the mysql database server.
    
    mysql_connect ($dbhost, $dbusername, $dbuserpass);
    
    if (!mysql_select_db($dbname)) die(mysql_error());
    
    $risultato=mysql_query("Select nome, cognome from utenti") or die ("non trovo la tabella");$numRecord=mysql_num_rows($risultato);if($numRecord!=0){while($record=mysql_fetch_array($risultato)){
    
    $nome = $record['nome'];
    
    
    echo"immagine=$nome";
    
    }
    }
    ?>
    Come faccio a far visualizzare anche il cognome dello stesso utente?

  2. #2
    ho risolto cosi':
    carica.fla
    due campi ti testo dinamico con istanza "nome", "cognome" ecc ecc, sul fotogramma chiave questo codice:
    codice:
    loader = new LoadVars();
    loader.load("recuperoDB.php");
    loader.onLoad = function(success) {
    if(success)
      {
      if(this.ok) 
        {
        _root.nome.htmlText = "";
        _root.cognome.htmlText = "";
    	_root.nickname.htmlText = "";
        _root.email.htmlText = "";
    	_root.passwort.htmlText = "";
        _root.indirizzo.htmlText = "";
    	_root.citta.htmlText = "";
        _root.sesso.htmlText = "";
        for(var j = 1; j <= this.i; j++)
           {
           _root.nome.htmlText += eval("this.nome" + j);
           _root.cognome.htmlText += eval("this.cognome" + j);
    	   _root.nickname.htmlText += eval("this.nickname" + j);
           _root.email.htmlText += eval("this.email" + j);
    	   _root.passwort.htmlText += eval("this.passwort" + j);
           _root.indirizzo.htmlText += eval("this.indirizzo" + j);
    	   _root.citta.htmlText += eval("this.citta" + j);
           _root.sesso.htmlText += eval("this.sesso" + j);
           }
        _root.output.text = "ok";
        }
      else
         {
         _root.nome.htmlText = "";
         _root.cognome.htmlText = "";
    	 _root.nickname.htmlText = "";
         _root.email.htmlText = "";
    	 _root.passwort.htmlText = "";
         _root.indirizzo.htmlText = "";
    	 _root.citta.htmlText = "";
         _root.sesso.htmlText = "";
         _root.output.text = "error";
         }
      }
    }
    recuperoDB.php questo:
    codice:
    <?php
    
    // dati per la connessione al database
    
    $db_host = "localhost";
    $db_user = "root";  
    $db_password = "";
    $db_name = "mamma";
    
    // connessione al database
    
    $db = mysql_connect ($db_host, $db_user, $db_password);
    $db_forum = mysql_select_db ($db_name, $db);
    
    $query = "SELECT `nome`, `cognome`, `nickname`, `email`, `passwort`, `indirizzo`, `citta`, `sesso` FROM `utenti` ORDER BY `cognome`";
    
    $query_results = mysql_query($query);
    $i = 0;
    
    while($fetch = mysql_fetch_array($query_results))
         {
         $i++;
         echo "&nome".$i."=".$fetch['nome'];
         echo "&cognome".$i."=".$fetch['cognome'];
    	 echo "&nickname".$i."=".$fetch['nickname'];
         echo "&email".$i."=".$fetch['email'];
    	 echo "&passwort".$i."=".$fetch['passwort'];
         echo "&indirizzo".$i."=".$fetch['indirizzo'];
    	 echo "&citta".$i."=".$fetch['citta'];
         echo "&sesso".$i."=".$fetch['sesso'];
         }
    
    if($i)
      {
      echo "&i=".$i;
      echo "&ok=1";
      echo "&stop=1";
      }
    
    else
       {
       echo "&ok=0";
       echo "&stop=1";
       }
    
    ?>
    La mia domanda adesso e', se un utente vuole modificare la sua password o email come devo fare? Con Update?

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.