Forum


Replies: 4   Views: 2840
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): ?>
         <tr>
               <td><?php echo $linha["name"]; ?></td>
         </tr>  
           <?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');
 
 $docx->replaceVariableByText($var,$option);

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

Hello,

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));

Regards.

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

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