Ive been on this for a while. What I am trying to do is create a CSV file from the while loop with CODE & QUANTITY then attach it to the email below then send. Any help would be greatly appreciated
$sql = mysql_query("SELECT code, quantity
FROM table
WHERE active = '1'
ORDER BY code Asc");
while($row = mysql_fetch_array($sql)){
$code = $row['code'];
$quantity = $row['quantity'];
//CREATE CSV FILE HERE I THINK?
}
$to = “email@gmail.com” ;
$from = “email@website.com”;
$subject = “Inventory”;
$message = ''<html>Code</html>'';
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: Inventory' . "\r\n";
mail($to, $subject, $message, $headers);
I want it to look something like this. The .csv file will be an attachment and Ill still display the regular email below it.