Forum


Replies: 5   Views: 3509
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  · 11-04-2013 - 12:13

[quote][b]Quote from admin on May 21, 2012, 10:55[/b]
Hello,

Please try and check easy/Template_chart.php example included in the library.

Regards.[/quote]

I've tried this way:

1) Opened the Template:[b] TemplateChart.docx[/b] used by the program easy/Template_chart.php
2) Copied the text of the template in mysql, in order to have the placeholder $PIECHART$ stored
3) modified the program
[code]<?php
require_once '../../classes/CreateDocx.inc';

mb_internal_encoding( 'UTF-8' );

// the intermediate file
$myfirstdoc = new CreateDocx();

$user = '###';
$user_password = '###';
$db_name = '###';

$conn = mysql_connect("localhost","$user","$user_password")or die("Connessione non riuscita: " . mysql_error());
mysql_select_db("$db_name", $conn) or die("Errore nella selezione del database");

mysql_query( "SET NAMES utf8", $conn );
mysql_query( "SET CHARACTER SET utf8", $conn );

$query="select nome from temp where tessera=1";

$result = mysql_query($query,$connessione);
$row = mysql_fetch_assoc($result);
$myfirstdoc = new CreateDocx();
$myfirstdoc->addText($row['nome']);
$myfirstdoc->createDocx('myfirstdoc');

// At this time "myfirstdoc.docx" should be equivalent to the original
Template used in the sample program: "../files/TemplateChart.docx"

// now begin the work on the final document

$docx = new CreateDocx();

//
// I use the first file as Template
//

$docx->addTemplate('myfirstdoc.docx');

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

$paramsChart =
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'
);

$docx->addTemplateChart('PIECHART', $paramsChart);

$docx->createDocx('../docx/template_chart');
[/code]


The result, using the "easy/Template_chart.php example included in the library"
is the same as above,
The placeholder $PIECHART$ is not replaced by the chart!!!