Revised:
I have these in my contractEmail.php:
if(isset($_POST['submit']) && $_POST['submit'] == 'Send') {
$size= sizeof($_POST['users']);
$i = 0;
$message = NULL;
// $message = null;
for($i=0; $i<$size; $i++){
$userId = $_REQUEST['users'][$i];
$message .= mailContent($userId);
}
$to = $_POST['email'];
$subject = 'This is a test';
$headers = 'From: xx@live.com.ph' . "
" .
'Reply-To: xx@live.com.ph' . "
" .
'X-Mailer: PHP/' . phpversion();
$headers .= 'MIME-Version: 1.0' . "
";
$headers .= 'Content-Type: text/html; charset=ISO-8859-1
';
mail($to, $subject, $message, $headers);
}
function mailContent($userId) {
$con=mysqli_connect("localhost","xx","xx","xx");
$stmt = "SELECT * from CV where idvisa = '$userId'";
$result = mysqli_query($con, $stmt);
$row=mysqli_fetch_array($result);
$fName = $row['fName'];
$lName = $row['lName'];
$visaNumber = $row['visanumber'];
$idNumber = $row['idnumber'];
$statusApp = $row['statusapp'];
$accntVisaPhotoPath = $row['accntVisaPhotoPath'];
$passportPath = $row['passportPath'];
$subdate = $row['subdate'];
$message = "<table>
<tr>
<th>Name</th><th>Visa Number</th><th>ID Number</th><th>Application Status</th><th>Visa Copy</th><th>Passport Copy</th><th>Date</th>
</tr>" . "
";
$message .= "<tr>
<td>$fName $lName</td><td>$visaNumber</td><td>$idNumber</td><td>$statusApp</td><td>$accntVisaPhotoPath</td><td>$passportPath</td><td>$subdate</td>
</tr>
</table>" . "
";
// OTHER LOGICS GO HERE
return $message;
}
echo "<center>You have sent CV(s) </b><br/><br/><br/><br/>YOU MAY NOW CLOSE THIS WINDOW</center>";
?>
but the problem is, it is not as expected. The th is repeating in an email up to 10 th. How to make the th appeared only once?
This is what I want:
| Name | Visa Number | ID Number |
| Jurie | 09254352654 | 5674356747 |
| Alex | 56756786797 | 5464654545 |
Here is my link
You are using the same variables in 11 (Table row). That is the reason of repeating in an email up to 10.
Dont put select person
in your select-option tag.
PS. you can var_dump($_POST['users']) to check out.