[英]Dynamically sent variables in a mail (PHP)
I have plus icon next to an input field in my form to so I can add more input fields. 我的表单中输入字段旁边有加号图标,因此我可以添加更多输入字段。 Name of the fields are automatically generated to in this form -> "one_f1", "one_f2" ...
字段名称以这种形式自动生成为->“ one_f1”,“ one_f2” ...
When I create the mail to send it out, I need to create a while loop for this so I can put all the values that are sent from the form. 创建邮件发送出去时,我需要为此创建一个while循环,以便可以放置从表单发送的所有值。 I am stuck while trying to add while loop in a variable called body because it has to be in the body of a mail.
我在尝试在名为body的变量中添加while循环时陷入困境,因为它必须位于邮件的正文中。
how can I fix this? 我怎样才能解决这个问题?
Here is the code; 这是代码;
$body ='
<ul>
while(isset($_POST["one_f".$i]))){
echo "<li style=\"list-style: circle;\">".$_POST["one_f".$i]".</li>";
}
</ul>
';
What's wrong with appending? 追加有什么问题?
$body = "<ul style=\"list-type-type:circle\">";
$i = 1; // whatever number the first field is
while(isset($_POST['one_f'.$i])) {
$body .= "<li>".$_POST['one_f'.$i]."</li>";
$i++; // you forgot this in your code!
}
$body .= "</ul>";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.