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

    come mai stampa doppio?

    ragazzi, una domanda, magari è idiota ... ma non capisco come mai a video mi stampa due volte per ogni campo .... ecco il codice

    codice:
    <?php
    
    $link = mysql_connect('localhost:/mysql/data/miodb', 'user', 'pw');
    mysql_select_db('miodb');
    
    $sql = "SELECT a.cognome, a.nome, a.citta, a.telefono, a.email, a.idcitta, b.citta as cittaisc FROM iscritto a, citta b where a.idcitta = b.idcitta order by b.citta, a.cognome, a.nome";
    $result = mysql_query($sql);
    $numfields = mysql_num_fields($result);
    $filename = "tmp/iscritti_".time().".csv"; 
    $handle = fopen($filename, 'w+'); 
    fputcsv($handle, array('cognome','nome','citta','telefono','email','cittaisc'));
    
    echo
    "<table width='80%' border='1' cellspacing='1' cellpadding='3'>
    <tr>"; 
    
    
    for ($i=0; $i < $numfields; $i++) 
    { 
    echo '<th>'.mysql_field_name($result, $i).'</th>'; 
    }
    echo "</tr>\n";
    
    while ($row = mysql_fetch_array($result)) 
    { 
    	echo '<tr><td>'.implode($row,'</td><td>')."</td></tr>\n"; 
    	fputcsv($handle, array($row['cognome'],$row['nome'], $row['citta'], $row['telefono'], $row['email'], $row['idcitta'], $row['cittaisc'])); 
    }
    echo "</table>\n";
    
    
    fclose($handle); 
    mysql_close($link);
    ?>
    ...e ricordatevi sempre che:
    ANCHE MICHELANGELO HA FATTO LE SUE CAPPELLE!
    io ho fatto:
    BizioWeb
    :mavieni:

  2. #2

    Re: come mai stampa doppio?

    Originariamente inviato da Bizioweb
    ragazzi, una domanda, magari è idiota ... ma non capisco come mai a video mi stampa due volte per ogni campo .... ecco il codice

    codice:
    <?php
    
    $link = mysql_connect('localhost:/mysql/data/miodb', 'user', 'pw');
    mysql_select_db('miodb');
    
    $sql = "SELECT a.cognome, a.nome, a.citta, a.telefono, a.email, a.idcitta, b.citta as cittaisc FROM iscritto a, citta b where a.idcitta = b.idcitta order by b.citta, a.cognome, a.nome";
    $result = mysql_query($sql);
    $numfields = mysql_num_fields($result);
    $filename = "tmp/iscritti_".time().".csv"; 
    $handle = fopen($filename, 'w+'); 
    fputcsv($handle, array('cognome','nome','citta','telefono','email','cittaisc'));
    
    echo
    "<table width='80%' border='1' cellspacing='1' cellpadding='3'>
    <tr>"; 
    
    
    for ($i=0; $i < $numfields; $i++) 
    { 
    echo '<th>'.mysql_field_name($result, $i).'</th>'; 
    }
    echo "</tr>\n";
    
    while ($row = mysql_fetch_array($result)) 
    { 
    	echo '<tr><td>'.implode($row,'</td><td>')."</td></tr>\n"; 
    	fputcsv($handle, array($row['cognome'],$row['nome'], $row['citta'], $row['telefono'], $row['email'], $row['idcitta'], $row['cittaisc'])); 
    }
    echo "</table>\n";
    
    
    fclose($handle); 
    mysql_close($link);
    ?>

    stampa a video:

    cognome nome citta telefono email idcitta cittaisc
    COGN COGN NOM NOM Roma Roma 3333333333 3333333333 mail@mail.com mail@mail.com 1 1 Roma Roma


    file creato:
    cognome,nome,citta,telefono,email,cittaisc
    COGN,NOM,Roma,3333333333,mail@mail.com,1,Roma
    ...e ricordatevi sempre che:
    ANCHE MICHELANGELO HA FATTO LE SUE CAPPELLE!
    io ho fatto:
    BizioWeb
    :mavieni:

  3. #3

    risolto "tamponando"

    per ora ho risolto cosi':

    codice:
    echo '<tr><td>'.$row['cognome']."</td><td>".$row['nome']."</td><td>".$row['citta']."</td><td>".$row['telefono']."</td><td>".$row['email']."</td><td>".$row['idcitta']."</td><td>".$row['cittaisc']."</td></tr>\n";

    ma preferivo mettere a posto il codice di prima, perchè era decisamente più pulito
    ...e ricordatevi sempre che:
    ANCHE MICHELANGELO HA FATTO LE SUE CAPPELLE!
    io ho fatto:
    BizioWeb
    :mavieni:

  4. #4
    Utente di HTML.it L'avatar di homerbit
    Registrato dal
    Dec 2005
    residenza
    Roma
    Messaggi
    1,380
    edit
    If you think your users are idiots, only idiots will use it. DropBox

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.