View Full Version : php and email

03-03-2007, 11:58 PM

I am sending emails using the code below:

$subject = $_POST['subject'];
$message = "hello there, this is an email";
$to = "alextrebsy57@hotmail.com";
$mailsend = mail($to,$subject,$message);

I have data from a database and want to send this in my email so it is displayed as in an html table in the email. I cannot get this to work as when I assign the html to the $message variable, the html doesnt render in the email, it only prints out the html.

Can anybody help please.


03-04-2007, 12:09 AM
Check Example 1050 at this link - http://www.php.net/manual/en/function.mail.php

03-04-2007, 01:05 PM
Thats great thanks, however my code is like this:

mysql_connect("mysql10.powweb.com", "", "") or die(mysql_error());
mysql_select_db("info") or die(mysql_error());

$result2 = mysql_query("SELECT team.TeamName, team.TeamID, League.LeagueID, League.Totalpts, SUM(selectedfootballerscore.TeamWeeklyScore), users.username FROM team, League, users, selectedfootballerscore WHERE (League.TeamID = team.TeamID) AND (selectedfootballerscore.TeamID = team.TeamID) AND (users.UserID = team.UserID) AND (League.LeagueID = '$LID') GROUP BY Totalpts");

echo "<table border=1><tr><td><font size=1 face='Verdana'>Team Name</font></td><td><font size=1 face='Verdana'>Manager</font></td><td><font size=1 face='Verdana'>Weekly Pts</font></td><td><font size=1 face='Verdana'>Total Pts</font></td><td></td></tr>";

while ($row2 = mysql_fetch_array($result2))
$messagept2 = "<tr><td><font size=1 face='Verdana'>" . $row2['TeamName'] . "</font></td><td><font size=1 face='Verdana'>" . $row2['username'] . "</font></td><td><font size=1 face='Verdana'>" . $row2['SUM(selectedfootballerscore.TeamWeeklyScore)'] . "</font></td><td><font size=1 face='Verdana'>" . $row2['Totalpts'] . "</font></td></tr>";
echo "</table>";

so basically data is read out of a database into an html table. This is the table I need to send. Are their hearders to send PHP? Can i save the results of my SQL query in an html table and just send it as an html table?