Output Blank?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Having some issues with outputting my table data as an array.

In the code below I am outputting the column titles of my table into an
excel spreadsheet. I get the column titles just fine in Excel.

if($numberFields) { // Check if we need to output anything
 $types = ifx_fieldtypes($query);
 if (isset($types)) {
  foreach($types as $field_name[] => $data_type) {
  }
 }
 $headers = join(',', $field_name)."\n"; // Make our first row in the CSV


After that I am pulling all of the column data to place under it's
respective title.

Uncommenting the print_r($info); below does display all of the data for each
column correctly. However, after I run my foreach loop and output the report
to Excel all I get is empty rows/columns where the data should be...on the
bright side I get the exact number of empty rows that my query should
return.

Any ideas why the data isn't populating? If I change $row[] =
parseCSVComments($info->$fieldName); to $row[] = parseCSVComments($info); I
get "Array" printed out in every cell.


 while($info = ifx_fetch_row($query)) {
 //print_r($info);
  foreach($field_name as $fieldName) { // Loop through the array of headers
as we fetch the data
   $row[] = parseCSVComments($info->$fieldName);
  } // End loop
  $data .= join(',', $row)."\n"; // Create a new row of data and append it
to the last row
  $row = ''; // Clear the contents of the $row variable to start a new row
 }
 // Start our output of the CSV
 header("Content-type: application/x-msdownload");
 header("Content-Disposition: attachment; filename=data.csv");
 header("Pragma: no-cache");
 header("Expires: 0");
 echo $headers.$data;
}

Thanks,
Dan

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux