Jump to content

Email Formatting


cerebrus189

Recommended Posts

So I have this page that outputs a sql query for required courses (healthcare field) and creates an email based on user input (variable). The email sends and I receive the information but the format is jacked up. My markup in the email shows.

 

As an example, I should be getting this.

 

Course                                            Date

Mandt Recert                                  1/16/2011

AWMD Recert                                  9/15/2010

 

etc, etc.

 

 

What I currently get in the email is this:

 

 

<table width=100% class="style11"><th align="left"><u>Course</u></th><th align="left"><u>Complete By</u></th><th align="left"> <th><tr><td width=33%>Abuse Neglect and Exploitation</td><td width=10%>12-31-1997</td><td width=33%></td></tr><tr><td width=33%>BloodBorne Pathogens Video</td><td width=10%>04-18-2008</td><td width=33%></td></tr><tr><td width=33%>MANDT Recert</td><td width=10%>08-11-2010</td><td width=33%></td></tr><tr><td width=33%>AWMD Recert</td><td width=10%>06-28-2011</td><td width=33%></td></tr><tr><td width=33%>CPR/1st Aid Combo</td><td width=10%>07-16-2012</td><td width=33%></td></tr></table></body></html>

 

 

<?php
	//connect to the database
	include 'dbcommon.php';
	$conn = mysql_connect($dbhost, $username, $password)
	  or die("Could not show the required classes." . mysql_error($conn));
	mysql_select_db($dbname);

	//grab the classes that are required
	$query="SELECT course, date_last_taken, certification FROM course_completions WHERE employee_id='" . $_REQUEST['employid'] . "' order by date_last_taken asc"; 
	$rs = mysql_query($query, $conn);
	$numrequired = mysql_num_rows($rs);

	$emailtext .= "<table width=100% class=\"style11\">";
	$emailtext .= "<th align=\"left\"><u>Course</u></th><th align=\"left\"><u>Complete By</u></th><th align=\"left\"> <th>";
	if ($numrequired == 0) {
	$emailtext .= "<html>\n";  
	$emailtext .= "<body>";
	$emailtext .= "<tr><td colspan=3>No classes required</td></tr>";
	}
	while ($results = mysql_fetch_array($rs))
	{
	  $emailtext .= "<tr>";
	  $emailtext .= "<td width=33%>";
	  $emailtext .= $results["course"];
	  $emailtext .= "</td>";
	  $emailtext .= "<td width=10%>";
	  $emailtext .= date("m-d-Y",strtotime($results["date_last_taken"]));
	  $emailtext .= "</td>";
	  $emailtext .= "<td width=33%>";
	  $emailtext .= "</td>";
	  $emailtext .= "</tr>";		  	  
	}
	$emailtext .= "</table>";
	$emailtext .= "</body>";
	$emailtext .= "</html>";
	echo $emailtext;

	mysql_close($conn);

	$headers .= "MIME-Version: 1.0\n";
	$headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\n";


	//email the results/		
	$email = $_REQUEST["email"];
	$comment = "message1";
	$subject = " ARCA Required Courses ";

	$message = $emailtext; 


	mail($email, $subject, $message);

	if ($mail) {
       echo "Email sent, click <a href=displaycourses.php?" . SID . ">here</a> to return.";
      }
      else {
        echo "There was a problem sending the email.";
      }

      ?> 
      
      

 

I'm sure the syntax isn't correct somewhere but I need help with the output of the email formatting.

 

Thanks!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.