Hello, dear friends.
Try to genereta table from table template. But some strange error, that I can't sove in 2 days.
THIS CODE WORKS FINE
====
$settings = array(
'header' => true
);
$docx->addTemplateVariable(
array(
array(
'TNUM' => 'Product A',
'TNAME' => '10',
'TPRICE' => '5',
'TEDIZ' => '5',
'TCOUNT' => '5',
'TSUMMA' => '5'
),
array(
'TNUM' => 'Product B',
'TNAME' => '10',
'TPRICE' => '5',
'TEDIZ' => '5',
'TCOUNT' => '5',
'TSUMMA' => '5'
),
array(
'TNUM' => 'Product C',
'TNAME' => '10',
'TPRICE' => '5',
'TEDIZ' => '5',
'TCOUNT' => '5',
'TSUMMA' => '5'
),
),
'table',
$settings
);
$docx->addTemplateVariable($table,'table',$settings);
====
THIS CODE DOESN'T WORKS
====
$settings = array(
'header' => true
);
$table = array();
$query = "SELECT * FROM `table`";
$sql = mysql_query($query) or die(mysql_error());
if (mysql_num_rows($sql) > 0){
$i = 1;
while ($row = mysql_fetch_array($sql)) :
$table[] = array(
'TNUM' => $i,
'TNAME' => $row["name"],
'TPRICE' => $row["price"],
'TEDIZ' => $row["edizm"],
'TCOUNT' => $row["count"],
'TSUMMA' => $row["total"]
);
$i++;
endwhile;
}
$docx->addTemplateVariable($table,'table',$settings);
====
How to correct gererate arrays to table tamplate?