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?

1 Answer 1

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.