【发布时间】:2020-09-07 14:34:17
【问题描述】:
我想在 php 更新/编辑表单中回显和更新这些选项。
这里是html输入动态文本框选项-
这里是完整的代码参考。 https://phppot.com/php/php-contact-form-with-custom-fields/
<div class="input-row">
<input style="width:49%!important; float:left;" type="text" placeholder="Option name" required class="custom-input-field" name="custom_name[]" />
<input style="width:49%!important; float:right;" type="number" placeholder="Price" min="0" step="0.01" required class="custom-input-field float-right" name="custom_value[]" />
</div>
输入数据库的代码
INSERT INTO custom_contact (name,email,subject,email_content,message,options) VALUES ('$name','$email','$subject','$emailContent','$message','$options')
if(!empty($_POST["custom_name"][0])) {
// $emailContent .= "<p><u>Custom Information:</u></p>";
foreach($_POST["custom_name"] as $k=>$v) {
$emailContent .= "" . $_POST["custom_name"][$k] . "-" . $_POST["custom_value"][$k] . ",";
}
}
如何在 php 中回显和编辑这些选项和字段
这是我的示例编辑/更新代码 - 我不知道在 value="" 中输入什么
例子-
<input style="width:49%!important; float:left;" type="text" placeholder="Option name" required class="custom-input-field" value="<?php echo$[0]["custom_name"];?>" name="custom_name[]" />
<input style="width:49%!important; float:right;" type="number" placeholder="Price" min="0" step="0.01" required class="custom-input-field float-right" value="<?php echo$["custom_value"][$k];?>" name="custom_value[]" />
【问题讨论】: