title: make excel from database and send it to mail in php
body: <p>i have created a excel file and i want to send it in mail . can anyone tell how can i do it .
  mail is going but excel file is not going .I am using mysql server in php .
  this is my code.</p>
  
  <pre><code>&lt;?php
  session_start();
   include ('../db_connect.php');
  
  $user = $_SESSION['album_id'];
  header("Content-type: application/vnd.ms-excel");
  header("Content-Disposition: attachment;Filename=selected_image.xls");
  
   echo "&lt;table&gt;";
  echo "&lt;tr&gt;";
  echo "&lt;td&gt;";
  echo "Imgae Name";
  echo "&lt;/td&gt;";
  echo "&lt;td&gt;";
  echo "Image Comment";
  echo "&lt;/td&gt;";
  echo "&lt;/tr&gt;";
  
  $select_all = "select * from select_album where user_inf_id = '".$user."' and status = '1'";
  $query_All = mysql_query($select_all) or die (mysql_error());
  while ($row_all = mysql_fetch_assoc($query_All))
  {
  echo "&lt;tr&gt;";
  echo "&lt;td&gt;";
  echo $row_all['user_image'];
  echo "&lt;/td&gt;";
  echo "&lt;td&gt;";
  echo $row_all['user_comment'];
  echo "&lt;/td&gt;";
  echo "&lt;/tr&gt;";
   }
  echo "&lt;/table&gt;";
  
                  $to         =   '2606ankit@gmail.com';  //put email address on which mail send
                 $subject     =   "TEST SUBJECT";                 //Put subject of mail here
                 $from        =   "webmaster@example.com";        //put email address from 
                 //email body start
                 $body        =   "Selected image mail";
  
                 // Always set content-type when sending HTML email
                  $headers = "MIME-Version: 1.0" . "\r\n";
                  $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
                  $headers .=  header("Content-type: application/vnd.ms-excel");
                  $headers .=  header("Content-Disposition: attachment;Filename=selected_image.xls");
                  // More headers
                  $headers .= 'From: '.$from. "\r\n";
  
                  //if you need to send cc mail then uncomment below line and change email address
                  //$headers .= 'Cc: myboss@example.com' . "\r\n";
  
                  mail($to,$subject,$body,$headers);
  
  
  ?&gt;
  </code></pre>
  
  <p>i have created a excel file and i want to send it in mail . can anyone tell how can i do it .
  mail is going but excel file is not going .I am using mysql server in php .</p>