I have a php page which displays class schedule data for each user from mysql database like this:
$result = mysql_query($sql);
echo "<table border='0'>
<thead>
<tr>
<th>Class Link</th>
<th>Student Skype ID</th>
<th>Student Name</th>
<th>Faculty Name</th>
<th>Class Name</th>
<th>USA Date (DD/MM/YY)</th>
<th>USA Start Time</th>
<th>USA End Time</th>
<th>India Date (DD/MM/YY)</th>
<th>India Start Time</th>
<th>India End Time</th>
<th>Status</th>
</tr>
</thead>";
while($row = mysql_fetch_array($result))
{
echo "<tbody>";
echo "<tr>";
echo "<td><a href=\"".$row['class_link']."\" target='blank'>Start Class</a></td>";
echo "<td>" . $row['skype_id'] . "</td>";
echo "<td>" . $row['student_name'] . "</td>";
echo "<td>" . $row['faculty_name'] . "</td>";
echo "<td>" . $row['subject_name'] . "</td>";
echo "<td>" . $row['date'] . "</td>";
echo "<td>" . $row['starttime'] . "</td>";
echo "<td>" . $row['endtime'] . "</td>";
echo "<td>" . $row['facdate'] . "</td>";
echo "<td>" . $row['facstarttime'] . "</td>";
echo "<td>" . $row['facendtime'] . "</td>";
echo "<td>" . $row['status'] . "</td>";
echo "</tr>";
echo "</tbody>";
}
echo "</table>";
now i have the following php email script
$to = 'support@xyz.com';
$subject = "Your Class Schedule";
$message = **'HOW CAN I PUT THE DATA FROM MYSQL HERE?'**;
$headers = 'From: REPLY@XYZ.COM' . "\r\n" .
$headers = "MIME-Version: 1.0" . "\r\n" .
$headers = "Content-type:text/html;charset=iso-8859-1" . "\r\n" .
'Reply-To: REPLY@XYZ.COM' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
As mentioned in the $message of the above code i would like to put this retrieved data into the $ message section so that it goes in the mail..
can anyone help?
depending on the source of your mysql data and how it is stored can’t you retrieve it and just add it to the $message variable?
format it as you with (HTML or not, etc) .. and mail away.
for multiple rows change the while up a little..
That pressumption is if you are using HTML formatted emails, otherwise it’ll just be formatted text.