Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //THIS FILE JUST CONTAINS THE DB CONNECTION AND THATS IT
- include_once "config.php";
- $table = 'patients'; // table you want to export
- $file = 'IME_Session'; // csv name.
- $result = mysql_query("SHOW COLUMNS FROM ".$table."");
- $i = 0;
- if (mysql_num_rows($result) > 0) {
- while ($row = mysql_fetch_assoc($result)) {
- $csv_output1 .= $row['Field'].";";
- $i++;}
- }
- $csv_output1 .= "\n";
- $values = mysql_query("SELECT * FROM ".$table."");
- while ($rowr = mysql_fetch_row($values)) {
- for ($j=0;$j<$i;$j++) {
- $csv_output2 .= $rowr[$j]."; ";
- }
- $csv_output2 .= "\n";
- }
- $filename = $file."_".date("d-m-Y_H-i",time());
- //THIS IS THE LINE THAT GIVES TROUBLE THAT DOESN'T LET ME DOWNLOAD THE CSV
- header("Content-type: application/vnd.ms-excel");
- header("Content-disposition: csv" . date("Y-m-d") . ".csv");
- header( "Content-disposition: filename=".$filename.".csv");
- print $csv_output1;
- print "<br>";
- print $csv_output2;
- exit;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement