This script looks fine but when i run it, the entire db is just echo'd all over the page. I didn't get any errors so not sure yet but i uploaded a spreadsheet to sql full of tasks and then each line i want to email to myself and if possible delete it after but i can manually do that anyway. The goal is just to array the email across each row.
<?php
$con = mysql_connect("localhost","root","toor");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("db", $con);
$result = mysql_query("SELECT * FROM tasks");
$to = "someone@somewhere.com";
$subject = "Results from query";
$body =
"<table border='1'>
<tr>
<th>CustomerID:</th>
<th>Name:</th>
<th>CompanyCode:</th>
<th>Country:</th>
<th>SalesRep:</th>
<th>City:</th>
<th>PostalCode:</th>
</tr>";
while($row = mysql_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['CustomerID'] . "</td>";
echo "<td>" . $row['Name'] . "</td>";
echo "<td>" . $row['CompanyCode'] . "</td>";
echo "<td>" . $row['Country'] . "</td>";
echo "<td>" . $row['SalesRep'] . "</td>";
echo "<td>" . $row['City'] . "</td>";
echo "<td>" . $row['PostalCode'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
$headers = 'From: someone@example.com';
mail($to,$subject,$body,$headers);
echo 'Mail sent to $to';
?>