Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何";获得;使用不同操作的混合表单中的正确值?_Php_Html_Forms - Fatal编程技术网

Php 如何";获得;使用不同操作的混合表单中的正确值?

Php 如何";获得;使用不同操作的混合表单中的正确值?,php,html,forms,Php,Html,Forms,当我写这样的表格时: <table> <form> <tr> <td><input name="newText" type="text" .../></td> <td><input type="submit" .../></td> </tr> </form> (repeat the above row several times

当我写这样的表格时:

<table>
  <form>
  <tr>
    <td><input name="newText" type="text" .../></td>
    <td><input type="submit" .../></td>
  </tr>
  </form>
  (repeat the above row several times for dynamically generated content)
</table>
<form>
<table>
  <tr>
    <td><input type="text" name="newText"/></td>
    <td><input type="submit" name="action" value="action1"/></td>
  </tr>
  (repeat rows several times with different values for the 'action' button)
</table>
</form>

(对动态生成的内容重复上述行数次)
这是不正确的HTML(IDE中生成了一个警告错误),我不确定它是否能在所有浏览器中正常工作

我不能把它们放在单独的表格中,因为那样会破坏所有的格式;td的宽度因内容而异,各表各不相同

然后我把整个表格从表格中拿出来,如下所示:

<table>
  <form>
  <tr>
    <td><input name="newText" type="text" .../></td>
    <td><input type="submit" .../></td>
  </tr>
  </form>
  (repeat the above row several times for dynamically generated content)
</table>
<form>
<table>
  <tr>
    <td><input type="text" name="newText"/></td>
    <td><input type="submit" name="action" value="action1"/></td>
  </tr>
  (repeat rows several times with different values for the 'action' button)
</table>
</form>

(使用“操作”按钮的不同值重复几行)
现在的问题是,最后生成的记录与
newText
值冲突,因此当从第一行提交表单时,提交的参数如下所示:

<table>
  <form>
  <tr>
    <td><input name="newText" type="text" .../></td>
    <td><input type="submit" .../></td>
  </tr>
  </form>
  (repeat the above row several times for dynamically generated content)
</table>
<form>
<table>
  <tr>
    <td><input type="text" name="newText"/></td>
    <td><input type="submit" name="action" value="action1"/></td>
  </tr>
  (repeat rows several times with different values for the 'action' button)
</table>
</form>
newText=text1
动作=动作1
newText=text2
newText=text3
newText=text4

所以我知道我需要执行
action1
,但我得到的只是
text4
作为值

如何获得正确的值?

您是否尝试过:

newText2 = text2
newText3 = text3
.
.
.
name=“newText[]”

您是否尝试过:

newText2 = text2
newText3 = text3
.
.
.

或者
name=“newText[]”

Ohh,我用[]设置名称,然后我可以像数组一样访问所有变量?Ohh,我用[]设置名称,然后我可以像数组一样访问所有变量?