Jump to content

Sending php/html document as an email using php mail() function


sophie17117

Recommended Posts

Okay so heres the dillio deal-

I need to send the following code in an email...but its a mix of php and html, and it retrieves various values from a database before sending...oh and i wouldnt mind the sending of the mail to be done on a button click!;)...anyways i have messed and messed but i aint too sure whether it can be done! Can someone please tell me the code and where i need to place it within my code? :queasy:

i'll post it all for whoever wants to take a look!

Thank you in advance :D

Ps...I know my code is off the wall, i'm like this when i java program too!!:rolleyes:

<html>

<link rel='stylesheet' type='text/css' href='style.css'>



<TITLE>Network Operation Centre Morning Bulletin- Preview Bulletin</TITLE>

<img align="left" align="top" src="TMDicon.JPG" alt="Icon" width="189" height="39">

<H2>Trader Media Digital Network Operation Centre Morning Bulletin</H2>

<body>
</br>

<?php
$connect= mysql_connect('localhost','sophie-j','sophie');
if (!$connect) { echo("ERROR: Not connecting" . mysql_error() . "\n"); }
mysql_select_db('sophie');
?>

<p align="center"><?php 
$day = date('l, ');
$dtoday = date('Y-m-d');
$time = date('H:i:sa');
$timez = date('O T');
print "Date: $day $dtoday Time: $time. Time zone: $timez"; ?>
</p>

<h2><b>Trader Media Digital - Service Issues:</b></h2>
<big><b> Current Service Issues: </b></big><br/>
<b> Incidents: </b>
The following services are unavailable or otherwise affected, as of 10:00 this morning:<br/><br/>

<?php
$result = mysql_query("SELECT * FROM bulletin_data WHERE `RepDate` = '$dtoday'");

echo "<table border='1' cellspacing='0' cellpadding='0'>
<tr>
<th><b><font color='darkblue'>Country</font></b></th>
<th><b><font color='darkblue'>Service</font></b></th>
<th><b><font color='darkblue'>Status Description</font></b></th>
<th><b><font color='darkblue'>RefNo</font></b></th>
</tr>";


while($row = mysql_fetch_array($result)) {
  echo "<tr>";
  echo "<td><font color='darkblue'>" . $row['Country'] . "</font></td>";
  echo "<td><font color='darkblue'>" . $row['Service'] . "</font></td>";
  echo "<td><font color='darkblue'>" . $row['StatusDesc'] . "</font></td>";
  echo "<td><font color='darkblue'>" . $row['RefNo'] . "</font></td>";
  echo "</tr>";
}
echo "</table>";

echo "</table>";
echo "</br>";

echo "<big><b>Historic service issues:</b></big></br>";
echo "Listed below are significant incidents encountered in the last 24 hrs that have been resolved:<br/><br/>";


$results = mysql_query("SELECT * FROM bulletin_data WHERE `RepDate` = '$dtoday'");

echo "<table border='1' cellspacing='0' cellpadding='0'>
<tr>
<th><b><font color='darkblue'>Country</font></b></th>
<th><b><font color='darkblue'>Service</font></b></th>
<th><b><font color='darkblue'>Summary</font></b></th>
<th><b><font color='darkblue'>Impact</font></b></th>
<th><b><font color='darkblue'>Time Period</font></b></th>
<th><b><font color='darkblue'>PastRefNo</font></b></th>
</tr>";

while($row = mysql_fetch_array($results)) 
  {
  echo "<tr>";
  echo "<td><font color='darkblue'>" . $row['PastCountry'] . "</font></td>";
  echo "<td><font color='darkblue'>" . $row['PastService'] . "</font></td>";
  echo "<td><font color='darkblue'>" . $row['IssueSummary'] . "</font></td>";
  echo "<td><font color='darkblue'>" . $row['IssueImpact'] . "</font></td>";
  echo "<td><font color='darkblue'>" . $row['TimePeriod'] . "</font></td>";
  echo "<td><font color='darkblue'>" . $row['PastRefNo'] . "</font></td>";
  echo "</tr>";
  }

echo "</table>";

echo "</br><br/>";

echo "<h2><b>Trader Media Digital - NOC News:</b></h2>";

echo "<b><big>Deployments and Maintenance News for Today:</big></b><br/>";

echo "<br/><b><font color='red'>Service Affecting Deployments and Maintenance</font></b>";

$todayd = date('Y-m-d');
$resul = mysql_query("SELECT * FROM `bulletin_data` WHERE `RepDate` = '$todayd' AND `ServiceAffect` !=('NULL')");


echo "<table border='0'>";
while($row = mysql_fetch_array($resul))	
    {
     echo "<tr>";
     echo "<td><font color='red'>". $row['ServiceAffect']."</font></td>";
     echo "</tr>";
    }
echo "</table>";

echo "<br/><b><font color='darkblue'>Non-Service Affecting Deployments and Maintenance</font></b>";

$todaydy = date('Y-m-d');
$res = mysql_query("SELECT * FROM bulletin_data WHERE `RepDate` = '$todaydy' AND `NonServiceAffect` !=('NULL')");

echo "<table border='0'>";
while($row = mysql_fetch_array($res))	
    {
     echo "<tr>";
     echo "<td><font color='darkblue'>". $row['NonServiceAffect']."</font></td>";
     echo "</tr>";
    }
echo "</table>";

echo "<br/><br/><b><big>Deployments and Maintenance News for Tomorrow:</big></b><br/>";

echo "<br/><b><font color='red'>Service Affecting Deployments and Maintenance</font></b>";

$dytoday = date('Y-m-d');
$reslt = mysql_query("SELECT * FROM bulletin_data WHERE `RepDate` = '$dytoday' AND `ServAffectTomrw` !=('NULL')");

echo "<table border='0'>";
while($row = mysql_fetch_array($reslt))	
    {
     echo "<tr>";
     echo "<td><font color='red'>". $row['ServAffectTomrw']."</font></td>";
     echo "</tr>";
    }
echo "</table>";

echo "<br/><b><font color='darkblue'>Non-Service Affecting Deployments and Maintenance</b></font>";

$todayday = date('Y-m-d');
$resu = mysql_query("SELECT * FROM bulletin_data WHERE `RepDate` = '$todayday' AND `NonServAffectTomrw` !=('NULL')");

echo "<table border='0'>";
while($row = mysql_fetch_array($resu))	
    {
     echo "<tr>";
     echo "<td><font color='darkblue'>". $row['NonServAffectTomrw']."</font></td>";
     echo "</tr>";
    }
echo "</table>";




echo "<p align='center'>Click 'Return' to go back and enter more data or click 'Send' to send the NOC Bulletin via e-mail.</p>";
echo "<p align='center'><input type='button' value='Return' onClick=\"window.location='http://nlwapp103/nocapps/sophie/'\">";
echo "<p align='center'><input type='button' value='Send' onClick='\"window.location='http://nlwapp103/nocapps/sophie/'\">";
msql_close($connection);

?>

</body>[color=black][/color]
</html>

Link to comment
Share on other sites

ok sorry i took a better look to your post...

your subject was misleading....

 

Now you want all these results of this script to be sent over an email...

 

Instead of printing them using echo or print put them in a var as strings very simply

$email_body .= ''

 

Then you will need to send this using the mail function... Use the things you read to the php manual in order to send the email as HTML and not plain text... If you have more problems repost here...

 

Kathas

 

Edit.: Don't forget to add to the variable the HTML code before the php opening tags

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.