php - 具有相同名称的多个表单数据

标签 php html

<分区>

我有一个 html 表单,多个数据具有相同的名称。像这样……

HTML代码

<tr>
  <td valign="top"><input id="" type="text" name="asset_id" size="15"/></td>
  <td valign="top"><input id="" type="text" name="batch_code" size="15"/></td>
  <td valign="top"><input id="" type="text" name="description" size="50"/></td>
</tr>
<tr>
  <td valign="top"><input id="" type="textbox" name="asset_id" size="15"/></td>
  <td valign="top"><input id="" type="textbox" name="batch_code" size="15"/></td>
  <td valign="top"><input id="" type="textbox" name="description" size="50"/></td>
</tr>

如何在 php $_POST[] 中将其发送到后端进程。请帮帮我..

最佳答案

方括号 [] 附加到您的名字:

<tr>
    <td valign="top"><input id="" type="text" name="asset_id[]" size="15"/></td>
    <td valign="top"><input id="" type="text" name="batch_code[]" size="15"/></td>
    <td valign="top"><input id="" type="text" name="description[]" size="50"/></td>
</tr>
<tr>
    <td valign="top"><input id="" type="textbox" name="asset_id[]" size="15"/></td>
    <td valign="top"><input id="" type="textbox" name="batch_code[]" size="15"/></td>
    <td valign="top"><input id="" type="textbox" name="description[]" size="50"/></td>
</tr>

在你的 php 中:

<?php
    print_r( $_POST['asset_id'] );
    print_r( $_POST['batch_code'] );
    print_r( $_POST['description'] );
?>

关于php - 具有相同名称的多个表单数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12083723/

相关文章:

javascript - AngularJs:当放置在 ng-view 标签内时,ng-include 不起作用

php - preg_match() : Compilation failed: invalid range in character class at offset

javascript - 使用jquery问题验证和提交表单

php - 多重继承支持

php - 如何从图像资源创建 base64 编码的字符串

css - 文本显示在 div 外部

html - 淡入并反射(reflect) CSS,不起作用

php - 在 SQL Select 中正确排序小数数据

javascript - shadow DOM 中的 addEventListener

html - 悬停 css 不起作用,容器元素留在白色背景中