Replies: 4   Views: 1054
Dynamic 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 Tiago Scalco de Mello  · 28-03-2017 - 00:05

How do I put data from a database directly into a table for docx?


 In html use foreach to traverse all cando and create table

 <?php foreach($consulta1 as $linha): ?>
               <td><?php echo $linha["name"]; ?></td>
           <?php endforeach; ?>

But I do not want to use html


Posted by Tiago Scalco de Mello  · 28-03-2017 - 16:57

Need to add breaks between names , how to use 'parseLineBreaks'

$arr = array('john', 'Cyrax', 'john', 'Sonia', 'Sector'); //DATABASE

 $var = array('campus' => $arr);
$option = array('parseLineBreaks => true');

Posted by admin  · 28-03-2017 - 18:30


You need to use a string separated by '\n'. For example:

$multiline = 'This is the first line.\nThis is the second line of text.';
$variables = array('MULTILINETEXT' => $multiline);
$options = array('parseLineBreaks' =>true);
$docx->replaceVariableByText($variables, $options);

If you have an array with data, you can join it with '\n' :

$string_data = implode('\n', $array);
$variable = array('VAR_DATA' => $multiline););
$docx->replaceVariableByText($variable, array('parseLineBreaks' =>true));


Posted by Tiago Scalco de Mello  · 02-04-2017 - 20:26

Deleted by Tiago Scalco de Mello · 03-04-2017 - 01:44