[英]How to update dynamic options in php form
I want to divide and update dynamic options in input boxes in php form我想在php形式的输入框中划分和更新动态选项
Here is the output这是 output
test1-$11,test2-$23,test3-$12
I can add this fields in db just fine.我可以在数据库中添加这个字段就好了。
if(!empty($_POST["custom_name"][0])) {
foreach($_POST["custom_name"] as $k=>$v) {
$priceoptions .= "" . $_POST["custom_name"][$k] . "-$" . $_POST["custom_value"][$k] . ",";
I want to display fields in input boxes and add or update them like this...............我想在输入框中显示字段并像这样添加或更新它们......
Here is the reference code - https://phppot.com/php/php-contact-form-with-custom-fields/这是参考代码 - https://phppot.com/php/php-contact-form-with-custom-fields/
I try to get your output via php.我尝试通过 php 获取您的 output。 maybe it will help you
也许它会帮助你
<?php
$color="test1-$11,test2-$23,test3-$12";
$re = '/[a-zA-Z0-9]+-\$[0-9]+/m';
preg_match_all($re, $color, $matches, PREG_SET_ORDER, 0);
foreach ($matches as $key => $value) {
$value = $value[0];
$label = explode('-',$value)[0]; // get label from string
$value = explode('-',$value)[1]; // get value from string
$value = str_replace('$','',$value); // repalce '$'
?>
<div>
<input type="text" value="<?php echo $label?>">
<input type="text" value="<?php echo $value?>">
</div>
<?php
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.