1

I am making a php application for saving data, it is using table inside form, I want to save data from table to mysql using PHP.

Parse html table using file_get_contents to php array I am coming through this question but in this the DOM loading another file, but my table is in the same file.

can any one suggest me how can I do this?

Community
  • 1
  • 1
Mandeep Singh
  • 2,016
  • 7
  • 19
  • 32

1 Answers1

0

There are 2 ways I can think of doing this:

1 - You could define the table as a variable, and echo it, inside a PHP block, so that you have the data for parsing:

<?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);

2 - You could also grab the data using an output buffer, :

<?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);
Steven Moseley
  • 15,871
  • 4
  • 39
  • 50