使用php将数据从html表插入mysql

使用php将数据从html表插入mysql,php,html,Php,Html,我正在制作一个用于保存数据的php应用程序,它使用表单中的表,我想使用php将表中的数据保存到mysql 我正在讨论这个问题,但是在这个问题中,DOM加载了另一个文件,但是我的表在同一个文件中 有谁能建议我怎么做吗?我可以想到两种方法: 1-您可以将该表定义为一个变量,并在PHP块中回显它,以便获得用于解析的数据: <?php // define the table with heredoc $data = <<<HTML <table>

我正在制作一个用于保存数据的php应用程序,它使用表单中的表,我想使用php将表中的数据保存到mysql

我正在讨论这个问题,但是在这个问题中,DOM加载了另一个文件,但是我的表在同一个文件中


有谁能建议我怎么做吗?

我可以想到两种方法:

1-您可以将该表定义为一个变量,并在PHP块中回显它,以便获得用于解析的数据:

<?php
// define the table with heredoc
$data = <<<HTML

    <table>
        ...
    </table>
HTML;

// print the table
echo $data;

// follow the instructions from your link here
parseTable($data);

...
<?php
// start a buffer
ob_start();
?>
<table>
        ...
</table>
<?php
// get the table in a variable 
$data = ob_get_contents();

// flush the buffer to output
ob_end_flush();

// follow the instructions from your link here
parseTable($data);