I have a email script that sends out information from the mysql database with the following code, but it only sends out one name and ID, but in the email it should send all 20 names and IDs. My question how can I get this fix and working right. Thanks for any help.
//retreive questions from database and put into question box
$query2 = "SELECT `studentID`,`studentName` FROM `quiz1question`";
$question2 = mysql_query($query2);
while($row = mysql_fetch_array($question2)){
$studentName = $row['studentName'];
$studentID = $row['studentID'];
$msg .= '<p>Student Name: '.$studentName.' or Student ID: '.$studentID.'</p>';
// ------------------------------------------------------------
$to = "cc-wp@hotmail.com";
$subject = "CT-80 Quiz/Test Results";
$from = "akamerc@hotmail.com";
$headers ="From: $from\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1 \n";
if(mail($to,$subject,$msg,$headers)) {
echo "success";
exit();
} else {
echo "failed";
exit();
}
?>
<?php } ?>