I am trying to output a table using FPDF and PHP.
What I need is to output the table headings and I have a doctrine (symfony) collection.
I’m using the writeHTML method using:
$pdf->writeHTML('<table>','','','','');
$pdf->writeHTML('<tr><th>Tooth Selection</th><th>Requirements</th><th>Shade</th><th>Cost</th></tr>','','','','');
$order_items = $this->order_details->getIncludedItemsOrders();
foreach($order_items as $item)
{
$pdf->writeHTML('<tr><td>Test1</td><td>Test2</td><td>Test3</td><td>test4</td></tr>', '','');
}
$pdf->writeHTML('</table>');
But I get errors, such as:
Notice: Undefined index: cols in
Notice: Undefined variable: cellspacingx in
Am I doing this correct as I can’t find much information regarding outputting tables using a foreach
Thank
That’s FPDF for you. It’s full of code that raises E_NOTICE errors. If you need to stay with FPDF, you need to turn E_NOTICE off.
I’d recommend moving to a newer and better amintained library like TCPDF though.