Forum


Replies: 7   Views: 217
Create a while loop in php to create a table
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by admin  · 16-05-2019 - 10:18

Hello,

To accomplish that task using a template you can:

$docx = new CreateDocxFromTemplate('template.docx');

$data = array(
    array(
        'ITEM' => 'Product A',
        'REFERENCE' => '107AW3',
    ),
    array(
        'ITEM' => 'Product B',
        'REFERENCE' => '204RS67O',
    ),
    array(
        'ITEM' => 'Product C',
        'REFERENCE' => '25GTR56',
    ),
);
$docx->replaceTableVariable($data);

How to extract the information and generate an array from it depends on the function or method you are using to access the database: mysql functions, PDO, ORM...

We recommend you to check the included samples and the information available on the API pages of each method, that illustrate how to accomplish these kind of tasks.

Regards.