 | Newbie | | Join Date: Feb 2007 Location: I am from Pakistan
Posts: 25
| |
| re: export data to xls format
Hello Sejal Mandaliya,
I send you the script that make your work easy....
Reply me hows its worked.
Regards
zabsmarty -
-
<?php
-
//include db connection file
-
-
include 'connection.php';
-
-
$query = "SELECT first_name, last_name, preferred_name, nick_name, ethnicity, gender, email, mobile, phone, line_1,line_2, subrub, city,country, graduating_university, year_graduation, level_training, level_training_year, hospital_main, vocational_interest_1 FROM members ";
-
-
$result = mysql_query($query) or die('Error, query failed');
-
-
$tsv = array();
-
$html = array();
-
while($row = mysql_fetch_array($result, MYSQL_NUM))
-
{
-
$tsv[] = implode("\t", $row);
-
$html[] = "<tr><td>" .implode("</td><td>", $row) . "</td></tr>";
-
}
-
-
$tsv = implode("\r\n", $tsv);
-
$html = "<table>" . implode("\r\n", $html) . "</table>";
-
-
$fileName = date("d-m-Y").'_mysql.xls';
-
header("Content-type: application/vnd.ms-excel");
-
header("Content-Disposition: attachment; filename=$fileName");
-
-
//echo $tsv;
-
echo $html;
-
-
//include 'library/closedb.php';
-
header('location:thanks.php');
-
?>
-
-
-
Quote:
Originally Posted by sejal17 Dear Sir,
Can you tell me how to export data from MySQL database to a xls file using php code?I have to export data from different tables of mysql database to a single xls file.Please help me!!!
Regards,
Sejal Mandaliya |