I am trying to get some generic code to work, which will take a table and dump the elements into a tab delimited file that can then be opened in a spreadsheet.
I think I am getting close with this:
It works except each row in the file has each element twice. I don't see how that is happening. All the elements are there and all the rows are in separate lines as I want. But each line has each element value twice.Code:$query = mysql_query("SELECT * FROM `members`"); while ($row = mysql_fetch_array($query)) { foreach ($row as $element) $output .= $element."\t"; $output .= "\r\n"; @file_put_contents($file,$output,FILE_APPEND|LOCK_EX); unset($output); }
The other thing I would like to do is have a first row with the element name. I figure that would take another query initially as the first line in the output file, then start over with the code above. But I am not sure how to extract the element names in the row.
Any help would be greatly appreciated.


Reply With Quote
Bookmarks