Ver Mensaje Individual
  #5 (permalink)  
Antiguo 05/05/2014, 09:21
ElleLawliet
 
Fecha de Ingreso: noviembre-2013
Mensajes: 47
Antigüedad: 10 años, 5 meses
Puntos: 0
Respuesta: fputcsv para guardar en un excell en mas de 1 columna

Pues es muy raro... A mi me lo mete todo en la columna A, mira lo acabo de probar asi (e copiada el for que has puesto en tu ultimo post para probar)

Código PHP:
                        // This include gives us all the WordPress functionality
                        
include_once($_SERVER['DOCUMENT_ROOT'].'/wp-load.php' );

                        
/*
                         * Make sure to use some namespacing for your functions:
                         * Mine for this example: "fz_csv_"
                         */
                        
function fz_csv_export() {
                            
// This line gets the WordPress Database Object
                            
global $wpdb;

                            
// Here's the query, split up for easy reading
                            
$qry = array();
                            
$qry[] = "SELECT field_name, field_val";
                            
$qry[] = "FROM wp_cformsdata";
                            
$qry[] = "ORDER BY f_id";

                            
/*
                             * Use the WordPress database object to run the query and get
                             * the results as an associative array
                             */
                            
$result $wpdb->get_results(implode(" "$qry), ARRAY_A);
                            
//page, title, Nombre, Apellidos, Empresa, Telefono, email, Comentarios, Acepto";

                            // Check if any records were returned from the database
                              
if ($wpdb->num_rows 0) {
     
    
$filename "dades.csv";
     
    
header'Content-type: text/csv' );
    
header'Content-Disposition: attachment;filename='.$filename);
     
    
$fp fopen('dades.csv''w');
     
    
$hrow $result[0];
     
    
fputcsv($fp, array('page''title''Nombre''Apellidos''Empresa''Telefono''email''Comentarios''Acepto'));
     
    for(
$i 0$i 10$i++) {
        
fputcsv($fp, array('Nombre' $i'Apellido' $i'Empresa' $i));
    }
     
    
fclose($fp);
     
    }
                            
// This function removes all content from the output buffer
                            
ob_end_clean();

                        }

fz_csv_export() 


Debo tener algo mal...