Currently i have this code
<?php
$con = mysql_connect('localhost', $db_user, $db_pwrd) or die('Could not connect to database!');
mysql_select_db($db_name, $con);
require_once('games/secureWay.php');
if (isWayClear('join1')) {
$sql = "(SELECT url,alttext FROM cards WHERE type IN ('character','scene','puzzle') AND `deny`='no' ORDER BY RAND() LIMIT 4)
UNION
(SELECT url,alttext FROM cards WHERE type = 'special' AND `deny`='no' ORDER BY RAND() LIMIT 1)";
} else {
$sql = "(SELECT url,alttext FROM cards WHERE type IN ('character','scene','puzzle') AND `deny`='no' ORDER BY RAND() LIMIT 3)
UNION
(SELECT url,alttext FROM cards WHERE type = 'special' AND `deny`='no' ORDER BY RAND() LIMIT 1)";
}
$result = mysql_db_query($db_name, $sql, $con);
if (!$result) { echo( mysql_error()); }
while ($row = mysql_fetch_array($result)) {
$url = $row['url'];
$alttext = $row['alttext'];
echo " <img src=\"$url\" alt=\"$alttext\" />" ;
} ?>
What i want to do with it is send an email with the results of the sql queries, but i'm not sure where to put the mail. If i put it inside the while, i get 1 email per result, if i put it outside, i get 1 email, but with the last result. I want to get 1 email with all the results
This is the email code i'm using
// Send email to the seller
$to = "*****@midnighttempest.com";
$subject = "Midnight Tempest (Join)";
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$message = "
<html>
<head>
<title>Midnight Tempest (Join)</title>
</head>
<body>
<p>Thank you for joining Midnight Tempest. Don't forget that you will need to sign up on the forum.</p>
<p>Please use the same username on the forum as you have used here.</p>
<p>Don't forget that if you post a new topic in the Introductions forum you get extra goodies.</p>
<p>Here are your cards. They are the same ones you got on the join page.</p>
<img src=\"$url\" />
</body>
</html>";
mail($to, $subject, $message, $headers);
any help would be great