Jump to content

Reports in .xls then email to admin


needs_upgrade

Recommended Posts

Hello guys.

 

By the end of the day, my client wants the daily report sent to his email account in .xls format. how can i attain this? I know the php mail() function but i dont know how will php create an excel file and email it to my client automatically. Where should i start?

 

Thanks guys!

Link to comment
https://forums.phpfreaks.com/topic/216857-reports-in-xls-then-email-to-admin/
Share on other sites

I have found attachments a bit of a nightmare! Why not email a link?

$header="column name\t column name\t column name\t column name\t column name\t";
$select="select * from table_name where condition ";                
$export = mysql_query($select);
while($row = mysql_fetch_assoc($export)) {
    if(empty($row[a]))$row[a]=" ";
    if(empty($row[b]))$row[b]=" ";
    if(empty($row[c]))$row[c]=" ";
    if(empty($d[d]))$row[d]=" ";
    $line = ''; 
    $line .= "$row[first_name]\t $row[surname]\t $row[email]\t $row[phone]\t $lang[$key]\t"; 
    $data .= trim($line)."\n"; 
} 
$data = str_replace("\r","",$data); 
if ($data == "") { 
    $data = "\n(0) Records Found!\n";                         
} 
header("Content-type: application/x-msdownload"); 
header("Content-Disposition: attachment; filename=$file_name"); 
header("Pragma: no-cache"); 
header("Expires: 0"); 
print "$header\n$data";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.