Export file in excel formet from your data table


<?php
$result = mysql_query("SELECT * FROM contact");
if($_POST['Export']==Export)
{
$file_name="export.csv"; //name of export file you can change here
$titlelist="";
$titlelist="Contact Person,Address,City,State,Mobile,Email";
{
   header("Content-type: application/vnd.ms-excel");
header('Content-Disposition: attachment; filename="'.$file_name.'"');
//write proper data fetch syntax
$query= "select * from contact";
$stid=mysql_query($query);

print $titlelist.chr(13).chr(10);
while ($row = mysql_fetch_array($stid))
{
     print "{$row['firstname']}, {$row['address1']}, {$row['city']},{$row['state']},{$row['mobile1']},{$row['email1']}";
 print chr(13).chr(10);
}
}
    exit ();
}
?>

Comments

Popular Posta

How to enable .htaccess in wamp server

Web Scraping Amazon with PHP

Disable right click script and Google Instant Map Search