php - 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 行的电子邮件。任何帮助,将不胜感激!
解决方案
推荐阅读
- rust - Rust 内循环导致双重可变借用
- java - Wildfly 17.0.1.Final 上的部署问题
- .net - Xunit 未在 Visual Studio 2019 中运行某些测试
- maven - [Intellij][Maven] 如何使用项目作为对另一个项目的依赖
- robotframework - 使用Robot框架评估后如何使用0获取月份格式
- sql - PostgreSQL,插入前检查重复
- python - 使用 Python 构建 RPC 服务集群
- python - 无法从列表中添加 networkx 节点和链接
- reactjs - 如何使用反应钩子在 setInterval 中获取更新的道具?
- ruby-on-rails - 由于 Chrome,我被迫重新启动 Rails Server 以更新控制器中的修改