首页 > 解决方案 > For 循环正在通过电子邮件发送表格中的每行一个字符

问题描述

我一直在这个问题上停留了一段时间。我的要求是将数据从 mySQL 通过电子邮件发送到客户端。我从公司代码库中的另一个页面获取代码,该代码在通过电子邮件发送时有效。

在此处输入图像描述

我遇到的问题是每行只发送一个字符。

在此处输入图像描述

这是我的代码:

$message = "
                <br /><hr /><br /><table style='font-size: 12px; width:100%'>
                <tr>
                    <td td width='25%'><strong>Oligo Name</strong></td>
                    <td width='10%'><strong>Base</strong></td>
                    <td width='10%'><strong>Scale</strong></td>
                    <td width='10%'><strong>Mod</strong></td>
                    <td width='10%'><strong>Mod Position</strong></td>
                    <td style='word-break: break-all; width: 500px;'><strong>Oligo Sequence</strong></td>
                    <td width='15%' style='text-align: right'><strong>Price</strong></td>
                </tr>";
                $SampleID = 0;
                $maxrow = $OligoQty;
                for ($i; $i < $maxrow; $i++) {
                    if(trim($SampleName) == '' && trim($Sequence) == '')
                            continue;
                            // $SampleID++; 
                    $bases = preg_replace('/\s+/', '', $Sequence); 
                    $seq_length = strlen($bases);
                    $message .= "
                                <tr>
                                <td width='200'>{$SampleIDS} . {$SampleName[$i]}</td>
                                <td width='40'>{$sequence_length[$i]}</td>
                                <td width='40'>{$SampleScale[$i]}</td>
                                <td width='40'>{$modification[$i]}</td>
                                <td width='40'>{$mod_position[$i]}</td>
                                <td style='word-break: break-all; width: 500px;'>{$Sequence[$i]}</td>
                            </tr>";
                                </tr>";
                }

当我删除 for 循环时,它会完美地打印出该行:

在此处输入图像描述

我相信我的 for 循环有问题导致它这样做,我不知道为什么。我将 $maxrow 硬编码为 2,这就是为什么我得到 2 行的电子邮件。任何帮助,将不胜感激!

标签: phphtmlmysql

解决方案


推荐阅读