ob_start / ob_get_clean发送电子邮件至html php内容/结果

时间:2012-05-20 19:11:06

标签: php html email ob-start

我确定还有其他更好的方法,我不知道 - 只是尝试采用最简单的方法。将根据需要发布其他代码:

从上一页选择php结果:

                <div id="stage1sat" class="stageBox">
    <h3>STAGE 1</h3>
    <table>
    <?php

    ob_start();
    if ( ! empty($_POST['id']))
    { foreach($_POST['id'] as $key => $id) { $_POST['id'][$key] = mysql_real_escape_string($_POST['id'][$key]); } 
    $in = implode(', ', $_POST['id']); 
    $sqlSAT1 = "SELECT * FROM bandSched WHERE day='saturday' AND stage='stage 1' AND id IN ($in) ORDER BY FIELD(id, $in)"; 

    $result = mysql_query($sqlSAT1) or die('MySQL Error ' . mysql_errno() . ': ' . mysql_error()); 
    }
    if ( ! isset($result))
    {
    echo 'You did not select anything';
    }
    else
    {


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

    echo "<tr>";
    echo "<td>". $row['timeShow'] ."</td><td>" . $row['bandName'] . "</td>";
    echo "</tr>";
    }

    }

    ?>
    </table> 
    </div>

EmailProcess.php

      <?php

    $to = $_POST["email"];
    $subject = "FPSF SCHEDULE";
    $message = ob_get_clean();
    $headers = "From: The Server <server@doe.com>" . "\r\n" .
               "Content-type: text/html" . "\r\n";

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

  ?>

2 个答案:

答案 0 :(得分:1)

您可以使用ob_start()$message = ob_get_clean()包装这些php文件的结果。

或者更改那些php以将结果写入变量(而不是echo它们。)

答案 1 :(得分:0)

不确定您的问题..即使在阅读评论时也是如此。如果您可以访问php ini文件或能够打开输出缓冲设置。

相关问题