Visualizzazione dei risultati da 1 a 8 su 8

Hybrid View

  1. #1
    Utente di HTML.it
    Registrato dal
    Dec 2001
    Messaggi
    168
    Quote Originariamente inviata da las Visualizza il messaggio
    Certo, sostituisci all'asterisco i nomi delle colonne che vuoi estrarre:

    Codice PHP:
    $values mysql_query("SELECT mail,telefono,fax FROM ".$table.""); 

    ciao las e intanto grazie anche a te, ho fatto come dici tu e nello specifico
    codice HTML:
    $table = 'bp';
    $filename = 'bpfile';
    
    $link = mysql_connect($host, $user, $pass) or die("Can not connect." . mysql_error());
    mysql_select_db($db) or die("Can not connect.");
    
    //$result = mysql_query("SHOW COLUMNS FROM ".$table."");
    $result = mysql_query("select mail,telefono,fax FROM ".$table."");
    //echo $result;
    //exit;
    $i = 0;
    if (mysql_num_rows($result) > 0) {
    while ($row = mysql_fetch_assoc($result)) {
    $csv_output .= $row['Field']."; "; //ELIMINO INTESTAZIONE COLONNE
    $i++;
    }
    }
    $csv_output .= "\r\n";
    
    $values = mysql_query("SELECT * FROM ".$table."");
    while ($rowr = mysql_fetch_row($values)) {
    for ($j=0;$j<$i;$j++) {
    $csv_output .= $rowr[$j]."; ";
    }
    $csv_output .= "\r\n";
    }
    
    file_put_contents($filename.".csv",$csv_output);
    ma il file csv che mi esce non riporta intestazione colonna
    e come valori solo la prima colonna a sx con valore 1 alla prima riga utile e 2 alla seconda...
    non pesca dal db suppongo

    grazie per la pazienza!

  2. #2
    Utente di HTML.it
    Registrato dal
    Dec 2001
    Messaggi
    168
    Quote Originariamente inviata da daduz Visualizza il messaggio
    ciao las e intanto grazie anche a te, ho fatto come dici tu e nello specifico
    codice HTML:
    $table = 'bp';
    $filename = 'bpfile';
    
    $link = mysql_connect($host, $user, $pass) or die("Can not connect." . mysql_error());
    mysql_select_db($db) or die("Can not connect.");
    
    //$result = mysql_query("SHOW COLUMNS FROM ".$table."");
    $result = mysql_query("select mail,telefono,fax FROM ".$table."");
    //echo $result;
    //exit;
    $i = 0;
    if (mysql_num_rows($result) > 0) {
    while ($row = mysql_fetch_assoc($result)) {
    $csv_output .= $row['Field']."; "; //ELIMINO INTESTAZIONE COLONNE
    $i++;
    }
    }
    $csv_output .= "\r\n";
    
    $values = mysql_query("SELECT * FROM ".$table."");
    while ($rowr = mysql_fetch_row($values)) {
    for ($j=0;$j<$i;$j++) {
    $csv_output .= $rowr[$j]."; ";
    }
    $csv_output .= "\r\n";
    }
    
    file_put_contents($filename.".csv",$csv_output);
    ma il file csv che mi esce non riporta intestazione colonna
    e come valori solo la prima colonna a sx con valore 1 alla prima riga utile e 2 alla seconda...
    non pesca dal db suppongo

    grazie per la pazienza!

    ho fatto dei progressi!
    cosi mi funziona ma non mi scrive l' intestazione delle colonne..
    suppongo l' errore sia nella riga
    $csv_output .= $row['Field']."; "; //ELIMINO INTESTAZIONE COLONNE
    grazie!


    codice HTML:
    $table = 'bp';
    $filename = 'bpfile';
    
    $link = mysql_connect($host, $user, $pass) or die("Can not connect." . mysql_error());
    mysql_select_db($db) or die("Can not connect.");
    
    //$result = mysql_query("SHOW COLUMNS FROM ".$table."");
    $result = mysql_query("select mail,telefono,fax FROM ".$table."");
    //echo $result;
    //exit;
    $i = 0;
    if (mysql_num_rows($result) > 0) {
    while ($row = mysql_fetch_assoc($result)) {
    $csv_output .= $row['Field']."; "; //ELIMINO INTESTAZIONE COLONNE
    $i++;
    }
    }
    $csv_output .= "\r\n";
    
    //$values = mysql_query("SELECT * FROM ".$table."");
    $values = mysql_query("select mail,telefono,fax FROM ".$table."");
    while ($rowr = mysql_fetch_row($values)) {
    for ($j=0;$j<$i;$j++) {
    $csv_output .= $rowr[$j]."; ";
    }
    $csv_output .= "\r\n";
    }
    
    file_put_contents($filename.".csv",$csv_output);

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.