从HTML表格检索数据到PHP [英] Retrieve data from HTML table to PHP

查看:141
本文介绍了从HTML表格检索数据到PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个动态html表,我想用POST方法从表中检索数据。是否有可能做到这一点?你会推荐什么其他方式来实现这一点。
下面是我得到的一个简单示例:

I've got a dynamic html table and I want to retrieve the data from that table using the POST method. Is it possible to do this? What other ways would you recommend to achieve this. Here's a simple example from what I got:

<html>
      <form id="form1" method="post" action="process.php">
         <table id="tblSample" name="tblSample">
         <tbody>
            <tr>
                <td>
                John Appleseed
                </td>    
                <td>
                Australia
                </td>
           </tr>
           <tr>
              <td>
              Mary Poppins
              </td> 
              <td>
              USA
              </td>   
            <tr>  
          </tbody>
          </table> 
       </form>
</html>

也许可以将信息存储在javascript数组或变量中以便将其发布到动作中文件,我不确定。

Maybe it's possible to store the info in a javascript array or variable in order to post it to the action file, I'm not sure.

我不知道这是否有什么要做,但表格是动态生成的。行和单元格由用户使用javascript添加。

I don't know if this has anything to do, but the table is generated dynamically. The rows and cells are added by the user using javascript.

非常感谢您的回答。

推荐答案

除非使用表单元素( input textarea 等),并向它们添加 name 属性;那么,您可以通过 $ _ POST 来访问元素。

A table cannot be accessed as such, unless you use form elements (input, textarea, etc.) and add name attribute to them; then, you can access your elements with $_POST.

如果您的数据在表格中,检索我们数据的方式是使用JavaScript,使用 innerHTML

If you have your data in a table, the best way to retrieve our data is by JavaScript, using innerHTML.

这篇关于从HTML表格检索数据到PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆