0

Hi!

I need help with sending html email with all the records from two tables. I tried joint tables but it doesnt work as it should... Here is what i have

session_start();

if(!@$_SESSION["UserID"])
{
        header("Location: login.php");
        return;
}
?>

<?php
$con=mysqli_connect("...");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
$result = mysqli_query($con,"SELECT add_delete_record.content, handover.shipment_type FROM add_delete_record, handover ");

$body .= "<html><head>
<style type='text/css'>
table.email {

    background-color: white;
    font-size:10px; 
    font-family:Arial;
}

table.email td {
    border-width: 1px;
    padding: 5px;
    border-style: inset;
    border-color: #cccccc;
    background-color: white;
    -moz-border-radius: ;
}

table.email th {
    border-width: 1px;
    padding: 5px;
    border-style: inset;
    border-color: #cccccc;
    border-bottom:none;
    background-color: #f0f0f0;
    -moz-border-radius: ;
}

</style>
</head><body>

<p align='center' ><font style='font-size:25px;'>HANDOVER<hr /></font></p><br />";

while($row = mysqli_fetch_array($result))

$body .= "<li>" . $row['content'] . "</li>";

$body .= "<table border='0' cellpadding='0' cellspacing='0' class='email'><thead>
<tr>

<th>Shipment Type</th>

</tr></thead>";



$body .= "<tbody><tr><td>" . $row['shipment_type'] . "</td></tr>";

$body .= "</tbody></table></body></html>";

$to = "email@email.com";
$subject = 'Handover';

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

mail($to,$subject,$body,$headers);


mysqli_close($con);

If i want to send all records from one table, it works fine, but selecting records from two tables is a problem.

Any ideas?

Thank you!

2
Contributors
2
Replies
18
Views
4 Years
Discussion Span
Last Post by dbalas
0

i think there is an error in the mysql query: there is no WHERE part.

what is te respone if change line 17 to:

$result = mysqli_query($con,"SELECT add_delete_record.content, handover.shipment_type FROM add_delete_record, handover ") or die(mysqli_error($con));
0

Hi!

Thank you for your reply. I have created one more querry and added WHERE id=id to booth so now it looks like this

$result = mysqli_query($con,"SELECT * FROM add_delete_record WHERE id=id") or die(mysqli_error($con));


while($row = mysqli_fetch_array($result)){

    $body .= "<li>" . $row['content'] . "</li>";

    }

.........

$result2 = mysqli_query($con,"SELECT * FROM handover WHERE id=id") or die(mysqli_error($con));

while($row2 = mysqli_fetch_array($result2)){

$body .= "<tbody><tr><td>" . $row2['shipment_type'] . "</td></tr></tbody>
}

so now everything works.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.