drh19790711 2013-08-17 06:20
浏览 27
已采纳

perl mail函数html电子邮件不发送多个数组数据

I need to send users report to admin emails, here i am facing problem only one row data sending remain data not sending. if i submit 2 row data only one row going to email. if i send only one row it is working fine. can any one tell me how to send two rows of data to single email.

<form>
<div>S.No  <input type="text" name="sno[]" /></div>
<div>Work Report  <input type="text" name="report[]" /></div>
<div>Status  <input type="text" name="status[]" /></div>
--------------------------------------------------------
<div>S.No  <input type="text" name="sno[]" /></div>
<div>Work Report  <input type="text" name="report[]" /></div>
<div>Status  <input type="text" name="status[]" /></div>
<input type="submit" name="Submit" />
</form>

Code is

<?php
$sno = $_POST['sno'];
$report = $_POST['report'];
$status = $_POST['status'];
foreach($sno as $v => $i)
{
$sno[$v];
$report[$v];
$status[$v];
$html = "
<html>
<head>
<style>
table.fancy_table tbody td              
{
font-family:'Calibri';
font-size:15px; line-height:18px; color:#333; background-color:#fff;
word-wrap: break-word;
}
table.fancy_table       {border: 0px solid #dddddd; }
table.fancy_table th    {border: 0px solid #dddddd;  padding:4px; color:#993300; text-transform:uppercase; background-color:#FFFFFF; }
table.fancy_table td    {border: 1px solid #dddddd; background:#ffffff; padding:4px; text-align:left; , height:30px; }
table.fancy_table tbody td   { background:#FFFFFF;}           
table.fancy_table {border-collapse: collapse; border-spacing: 0; width:450px; margin:0 auto; margin-bottom:15px; }
</style>    

</head>
<body>
<table class='fancy_table'>
<tr>
<td span style='color:#993300'><strong>S.NO</span></td>
<td span style='color:#993300'><strong>Report</span></strong></td>
<td span style='color:#993300'><strong>STATUS</span></strong></td>
</tr>
<tr>
<td width='50'>$sno[$v]</td>
<td width='150'>$report[$v]</td>
<td width='130'>$status[$v]</td>
</tr>
</table>
</body>
</html> 
";  
}//endforeach

$crlf = "
";
$mime = new Mail_mime;
$mime->setHTMLBody($html);
$body = $mime->get();
$headers = $mime->headers($headers);
$mail = $smtp->send($recipients, $headers, $body);


$errmsg_arr[] =  'Mail Successfully Sent';
$errflag = true;
}
else
{
$errmsg_arr[] = 'Mail Not Sent';
$errflag = true;
}




?> 
  • 写回答

1条回答 默认 最新

  • drtsd7864 2013-08-17 06:29
    关注

    Put the data in foreach loop :

      <?php
    $sno = $_POST['sno'];
    $report = $_POST['report'];
    $status = $_POST['status'];
    
    $html = "
    <html>
    <head>
    <style>
    table.fancy_table tbody td              
    {
    font-family:'Calibri';
    font-size:15px; line-height:18px; color:#333; background-color:#fff;
    word-wrap: break-word;
    }
    table.fancy_table       {border: 0px solid #dddddd; }
    table.fancy_table th    {border: 0px solid #dddddd;  padding:4px; color:#993300; text-transform:uppercase; background-color:#FFFFFF; }
    table.fancy_table td    {border: 1px solid #dddddd; background:#ffffff; padding:4px; text-align:left; , height:30px; }
    table.fancy_table tbody td   { background:#FFFFFF;}           
    table.fancy_table {border-collapse: collapse; border-spacing: 0; width:450px; margin:0 auto; margin-bottom:15px; }
    </style>    
    
    </head>
    <body>
    <table class='fancy_table'>
    <tr>
    <td span style='color:#993300'><strong>S.NO</span></td>
    <td span style='color:#993300'><strong>Report</span></strong></td>
    <td span style='color:#993300'><strong>STATUS</span></strong></td>
    </tr>";
    foreach($sno as $v => $i)
    {
    $sno[$v];
    $report[$v];
    $status[$v];
    $html.="<tr><td width='50'>$sno[$v]</td><td width='150'>$report[$v]</td><td width='130'>$status[$v]</td></tr>";
    }//endforeach
    $html.="</table></body></html>";  
    
    
    $crlf = "
    ";
    $mime = new Mail_mime;
    $mime->setHTMLBody($html);
    $body = $mime->get();
    $headers = $mime->headers($headers);
    $mail = $smtp->send($recipients, $headers, $body);
    
    
    $errmsg_arr[] =  'Mail Successfully Sent';
    $errflag = true;
    }
    
    
    ?>
    

    Replace your full code with this one. Ahmar.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大