Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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?

share|improve this question

1 Answer

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);
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.