1

I'm new using PHP and I need a bit of help here.

I'd like to send a HTML table to another PHP file, and then, be to able to use this information (specifically I want to download this like DOC file).

I've seen a lot of information how to do it. But I haven't seen how to do without <tbody></tbody>. I have a dynamic table, so, the data is loading from an array. By the way, I'm using DataTable-jQuery to do it.

I have the following HTML code:

<form action="sectoresTable.php" method="post"> 
    <table id="sectoresTable">
        <thead>
            <tr>
                <th><b>#</b></th>
                <th><b>Numero</b></th>
                <th><b>Nombre</b></th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
    <button type="submit" style="margin-top: 20px;">Exportar</button>
</form>

and sectoresTable.PHP:

<?php 
    header("Content-type: application/vnd.ms-word");
    header("Content-Disposition: attachment; filename=TablaSectores.doc"); 

    echo '';
?>

By the way, to load the data into the table, I'm using the following script:

<script>
    $('#sectoresTable').DataTable({
        data: arraySectores
    });
</script>

In general all this is working good, I download a doc file but without information (and That is right because my echo is printing nothing.).

I understand that I need to use a foreach in my HTML code? But really, I'm not sure.

3
  • Is this all the code you have or is there more ? Commented Jul 20, 2015 at 21:59
  • This answer might help: stackoverflow.com/a/11536958/3044080 Commented Jul 20, 2015 at 22:02
  • yes, It's all... to load the data in the table, I have a script in javascript. It's very simple: $('#sectoresTable').DataTable({data: arraySectores}); Commented Jul 20, 2015 at 22:04

1 Answer 1

1

try to use an api,to export dynamic html table to doc file in php

http://www.phpclasses.org/package/2763-PHP-Convert-HTML-into-Microsoft-Word-documents.html
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.