/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// Export to CSV if($_GET['action'] == 'export') { $out = ''; // Put the name of all fields for ($i = 0; $i < $columns; $i++) { $out .= '"'.$l.'",'; } $out .="\n"; // Add all values in the table for ($i = 0; $i < $columns; $i++) { $out .='"'.$l["$i"].'",'; } $out .="\n"; } // Output to browser with appropriate mime type, you choose ;) //header("Content-type: text/csv"); //header("Content-type: application/csv"); echo $out; exit; }