Forum


Replies: 5   Views: 3530
Mysql and template
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 lorepra  · 21-05-2012 - 10:35

I have this text stored in mysql, in a table temp:

[quote]Well, here it goes: $PIECHART$ This is a simple[/quote]

I retrieve it with this code:

[code]$query="select text from temp where uid=1";
$result = mysql_query($query,$connessione);
$row = mysql_fetch_assoc($result);
$doc0 = new CreateDocx();
$doc0->addText($row['text']);
$doc0->createDocx('doc0');

$doc1 = new CreateDocx();
$doc1->addTemplate('doc0.docx');
$doc1->addTemplateVariable('PIECHART', 'NEW VALUE');
$doc1->createDocx('doc1');[/code]

and the result is as expected, the placeholder PIECHART is replaced.
I got:
[quote]Well, here it goes: NEW VALUE This is a simple[/quote]

but with this code:
[code]
$query="select nome from temp where tessera=1";
$result = mysql_query($query,$connessione);
$row = mysql_fetch_assoc($result);
$doc0 = new CreateDocx();
$doc0->addText($row['nome']);
$doc0->createDocx('doc0');

$legends = array(
'legend1' => array(10, 11, 12),
'legend2' => array(30, 21, 12),
'legend3' => array(40, 41, 42)
);

$Chart1 =
array(
'data' => $legends,
'type' => 'pie3DChart',
'title' => 'Title',
'cornerX' => 20,
'cornerY' => 20,
'cornerP' => 30,
'color' => 2,
'textWrap' => 0,
'sizeX' => 10,
'sizeY' => 10,
'jc' => 'right',
'showPercent' => 1,
'font' => 'Times New Roman'
);

$doc1 = new CreateDocx();
$doc1->addTemplate('doc0.docx');
$doc1->addTemplateChart('PIECHART', $Chart1);
$doc1->createDocx('doc1');
[/code]

in this case the placeholder is not replaced by the chart.
What I got is:
[quote]Well, here it goes: $PIECHART$ This is a simple[/quote]

I work with linux, the filesystem is natively utf-8, mysql is still using utf-8 and also php.

Any help would be appreciated,