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 😃
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',','');
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>
</html>

    Fixing the missing ' to make the syntax more readable:

    sophie17117 wrote:
    <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','','');
    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>
    </html>

      You need do all this first but instead of using echo, put it all into a single text field. You can use $mail_text .= "blah blah" to append on each line.

      Will be easiest to just do a search and replace:
      echo "
      for
      $variable_name .= "

      and then set your variable to blank at the start.

      Then pass it into the mail function as the body of the mail.

      You can choose the mail header to be either HTML or plain text. If you set it as the former your HTML will actually be parsed as such and it'll build a page the same as you'd see in a browser.

      EDIT: You'll obviously have to change your page slightly. At the moment it's a hybrid of HTML and embedded PHP statements so you'll need to have all the HTML in the above page added to your text variable that is the message body.

        not sure what you want, if you want read a file and send it out.

        //first, you set up the email headers, receipents etc.
        $to="...";
        $subject="...";
        $headers="...";
        $return_path="...";

        //pick up the file you want to send
        $html="http://www.yoursite.com/thefileyouwantosend.php";

        //file_get_contents read the entire file to a string.
        $message=file_get_contents ($html);

        //wraps the content string
        $message=wordwrap($message, 72);

        //send it out
        $result = mail($to, $subject, $message, $headers, "-f $return_path");

          I did the above and sent it to hotmail and outlook-
          Hotmail- Half formatted, some was HTML and some was code, didnt send at all when there was data in my tables from the database!
          Outlook- Just sent the code in an email, & not all of the code! All appeared as text&code. Wouldnt send if i had any data in tables from the database!
          Any further suggestions?
          😉

            set up the headers as

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

              If it is what you want, send the php/html page as it displays in the browser in a html format email. The above scripts should work.

              If you have some database problems, it should not be due to the mail scripts.

              1) First of all, you need to see if your php/html page display right in the browser.

              2) And then these codes just read the html page contents and send it out as html format email. It will be the same as you see in the browser. It is no different than to read a pure html document and send it out.

              3) you need to use the full web address in that page for the links, images etc., not relative address.

              Hope that helps.

                I got it working eventually, with your help and some tweeking!
                😃

                  Write a Reply...