Professional Documents
Culture Documents
Require "../Include/Connect - PHP" Require "../Include/Settings - PHP" $Stmt1 "SELECT Emailid FROM Partzf - Subscription"
Require "../Include/Connect - PHP" Require "../Include/Settings - PHP" $Stmt1 "SELECT Emailid FROM Partzf - Subscription"
php";
require "../include/settings.php";
$count = mysql_num_fields($result);
while($row = mysql_fetch_row($result)){
$line = '';
foreach($row as $value){
if(!isset($value) || $value == ""){
$value = "\t";
}else{
// # important to escape any quotes to preserve them in the data.
$value = str_replace('"', '""', $value);
// # needed to encapsulate data in quotes because some data might be multi line.
// # the good news is that numbers remain numbers in Excel even though quoted.
$value = '"' . $value . '"' . "\t";
}
$line .= $value;
}
$data .= trim($line)."\n";
}
// # this line is needed because returns embedded in the data have "\r"
// # and this looks like a "box character" in Excel
$data = str_replace("\r", "", $data);
// # This line will stream the file to the user rather than spray it across the
screen
header("Content-Type: application/vnd.ms-excel; name='excel'");
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=excelfile.xls");
header("Pragma: no-cache");
header("Expires: 0");
echo $header."\n".$data;