Hi,
I wanted to create a table using a query on my php page.
I created a query that returns several rows of 3 columns. I had trouble figuring out a way to format the results of the query so that they fit your syntax. I understand your syntax to basically describe a table as an array that contains one array for each row to be included in the table:
$wordtable=array(
array('row1col1','row1col2','row1col3'),
array('row2col1','row2col2','row2col3'),
array('row3col1','row3col2','row3col3'),
);
Finally, I came up with this, and it works very well:
$sql = "SELECT A, B, C FROM WHEREVER";
$result = mysql_query($sql) or die (mysql_error());
$i=0;
$rows_ra = array();
while ($row = mysql_fetch_assoc($result)) {
foreach ($row as $key => $value) {
$rows_ra[$i][$key] = $value;
}
$i++;
}
$paramsTable = array(
'border' => 'single',
'border_sz' => 10
);
$docx->addTable($rows_ra, $paramsTable);
$docx->createDocx('./roster_doc/hello_world_table');
This is a big breakthrough for me! Thanks for the tool!