Avatar of Jazzy 1012
Jazzy 1012
 asked on

Sending an email with html and php contents

<?php
error_reporting(E_ALL);
ini_set('display_errors' ,1);
require "connection.php";


$to = "jasmine@hotmail.com";
$subject = "CURRENT_DATE";
?>
<?php

$query= "SELECT client_id, count(client_id) AS rows, array_agg(insurance) AS insurance from vouchers WHERE parsing_date=CURRENT_DATE GROUP BY client_id";
$result = pg_query($conn,$query);

?>

<!DOCTYPE html>
<html>
<head>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
<link href = "http://fonts.googleapis.com/css?family=Roboto:400">

<style>
.responstable {
  margin: 1em 0;
  width: 100%;
  overflow: hidden;
  background: #FFF;
  color: #024457;
  border-radius: 10px;
  border: 1px solid #167F92;
  word-wrap: break-word;
}
.responstable tr {
  border: 1px solid #D9E4E6;
}
.responstable tr:nth-child(odd) {
  background-color: #EAF3F3;
}

</style>

</head>

<body>
<div class="container-fluid">
        <div>
        
          <h1>Clients</h1>
   
          
        </div>
        
<table class="responstable" rules='all' style='border-collapse: collapse;'>
<thead>
	<tr>
		<th>Client id</th>
		<th>Number of rows</th>
		<th>Insurance</th>
	 
	</tr>
</thead>
  <?php 
  	while($row = pg_fetch_array($result))
	{ 




$find ='{';
$replace = '' ;
$arr = $row['insurance'];
$insurance3= str_replace($find,$replace,$arr);
$insurance = str_replace('"','  ',$insurance3);

  ?>

  <tbody>


     <td><?php echo $row['client_id']; ?></td>
     <td><?php echo $row['rows'];?></td>   
     <td><?php echo $insurance; ?></td> 
      
    </tr>
  <?php  }

  
  ?>  </tbody>
</table>
 
</div>

</body>
</html> 


<?php 
$headers = "HI";
mail($to,$subject,$message,$headers);

?>

Open in new window


I want to send this email, but right now it only sends a blank email, I want it to send me the contents thats in the code, which is a report of 3 columns, I tried putting "$message = " are the start but I just got error.
PHP

Avatar of undefined
Last Comment
gr8gonzo

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
gr8gonzo

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
gr8gonzo

I -know- my answer was correct unless the OP left out details about his/her situation. If the OP doesn't need the answer anymore, that's fine, but my comment should be accepted.
Jazzy 1012

ASKER
Actually its not letting me send any php , I just receive a blank email
gr8gonzo

Hi Jasmine,

If you're interested in resolving the issue, we can continue working through it, although we need feedback from you if something doesn't work as expected. So if you want to continue getting this resolved, post your latest code after the changes I suggested.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck