I need your help. I want to send an email with data from 2 selects, one with only one row and another with several rows (details table).
Tested separately, works very well, but it doesn't work when I want to put both results in the text message.
**********************************************************************
working
************************************************************************
<?php
include_once('z_connection.php');
$stmt = $conn->prepare("select * from batches where batch_id=2")
$stmt->execute();
$batches= $stmt->fetchAll();
foreach($batches as $batch)
{
?>
<tr>
<td><?php echo $batch['comp_id']; ?></td>
<td><?php echo $batch['description']; ?></td>
<td><?php echo $batch['quantity']; ?></td>
</tr>
<?php
}
?>
--------
mail($to, $subject, $message, $headers);
**********************************************************************
working
************************************************************************
<?php
include('mailer.php');
require '../../connect/config.php';
$pdo = new mypdo();
$mail = new mymailer();
?>
$message = '<html>
<head></head>
<body>
<table border="1" cellspacing="3" width="20%">
<tr><td>Date:</td><td>'.$date.'</td></tr>
<tr><td>User:</td><td>'.$c_user.'</td></tr>
<tr><td>Email:</td><td>'.$to.'</td></tr>
<tr><td>FormulaId:</td><td>'.$formula_id.'</td></tr>
<tr><td>Product:</td><td>'.$c_product.'</td></tr>
<tr><td>Batch Quantity:</td> <td>'.$c_pquant.'</td></tr>
</table>
</body>
</html>';
mail($to, $subject, $message, $headers);
Here 2 images with what I need
Tested separately, works very well, but it doesn't work when I want to put both results in the text message.
**********************************************************************
working
************************************************************************
<?php
include_once('z_connection.php');
$stmt = $conn->prepare("select * from batches where batch_id=2")
$stmt->execute();
$batches= $stmt->fetchAll();
foreach($batches as $batch)
{
?>
<tr>
<td><?php echo $batch['comp_id']; ?></td>
<td><?php echo $batch['description']; ?></td>
<td><?php echo $batch['quantity']; ?></td>
</tr>
<?php
}
?>
--------
mail($to, $subject, $message, $headers);
**********************************************************************
working
************************************************************************
<?php
include('mailer.php');
require '../../connect/config.php';
$pdo = new mypdo();
$mail = new mymailer();
?>
$message = '<html>
<head></head>
<body>
<table border="1" cellspacing="3" width="20%">
<tr><td>Date:</td><td>'.$date.'</td></tr>
<tr><td>User:</td><td>'.$c_user.'</td></tr>
<tr><td>Email:</td><td>'.$to.'</td></tr>
<tr><td>FormulaId:</td><td>'.$formula_id.'</td></tr>
<tr><td>Product:</td><td>'.$c_product.'</td></tr>
<tr><td>Batch Quantity:</td> <td>'.$c_pquant.'</td></tr>
</table>
</body>
</html>';
mail($to, $subject, $message, $headers);
Here 2 images with what I need