I have simple code here,
But couldn't able to make it work. Is there any other way.?
It's sends HTML coding in email rather then table.
Is there another way to do so.?
OR How Do I create csv or excel and attached with email it self automatically.?
$to = "beback@gmail.com";
$subject = 'New Employee file';
$message = "<html>
<head>
<title>New Employee</title>
</head>
<body>
<p>Here IS the New Employee List</p>
<table border=1>
<tr>
<th>FirstName</th>
<th>LastName</th>
<th>POSNum</th>
<th>POSPassword</th>
<th>location</th>
</tr>
<tr>";
$table = "send_payroll"; // Enter Your Table Name
$sql = mysql_query("select last_name,
first_name,
pos_num,
pos_password,
store
from $table");
$columns_total = mysql_num_fields($sql);
while ($row = mysql_fetch_array($sql)) {
$message .="<tr>";
for ($i = 0; $i < $columns_total; $i++) {
$message .='<td>'.$row["$i"].'</td>';
}
$message .="</tr>";
}
$message .="</tr>
</table>
</body>
</html> ";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= "From: Nirav <be.gmail.com>\r\n";
echo "$message" ; //Display table correctly
mail($to, $subject, $message, $headers);