【问题标题】:how to get data from a specific table html $_POST[] in the form PHP如何以 PHP 形式从特定表 html $_POST[] 获取数据
【发布时间】:2019-02-04 04:57:06
【问题描述】:

在表格中,我有两个表格,例如 table#1、table#2。两个表都只发送一个 $_POST。如何获取数据表格,例如 table#1 ?是否可以在 $_POST ['table #1'] 中以某种方式进行选择?

<form id="prepForm" action="" method="POST">
<table id="1" class="table tabele-conclusions table-bordered">
    <thead>
        <tr>
            <th>Lp.</th>
            <th>desc</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <th scope="row">1</th>
            <td><input name="row1_desc" value=""/></td>
        </tr>
    </tbody>
</table>
<table id="2" class="table tabele-conclusions table-bordered">
    <thead>
        <tr>
            <th>Lp.</th>
            <th>desc</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <th scope="row">2</th>
            <td><input name="row2_desc" value=""/></td>
        </tr>
    </tbody>
</table>

【问题讨论】:

  • 欢迎来到 StackOverflow。请通过tour 环顾四周,通读HELP center,然后阅读How to 、What types of questions should I avoid asking? 并提供MCVE : Minimal, Complete, and Verifiable Example。如果周围的人可以轻松阅读并理解您的意思或问题所在,他们将更愿意提供帮助:)
  • "两个表都只发送一个 $_POST" 如何通过 POST 发送表?你能详细说明一下吗?
  • 将所有元素的name 属性定义为数组并像这样使用name = data[table1]['name']....
  • 在您编辑之后,我建议您阅读一些关于数据提交和表单如何在 HTML 和 PHP 中工作的教程。
  • 无需在此处定位您的“表”(因为它们在 $_POST 中不可用),您的输入字段都有名称,只需使用 $_POST['row1_desc'] 和 $_POST['row2_desc']

标签: php


【解决方案1】:

简单例子:

HTML

<form action="/post.php" method="POST">
   <input type="text" name="testinput" value="Hello world!" />
</form>

PHP:

<?php
  echo $_POST["testinput"]; // Hello world!
?>

编辑:当我给出这个回复时,问题中没有示例代码。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-07-16
    • 1970-01-01
    • 2022-11-19
    • 2011-03-10
    • 2020-02-16
    • 1970-01-01
    • 2021-06-24
    相关资源
    最近更新 更多