Making tables using FPDF for a pdf document is a common problem. Have a look at the easyTable project:
GitHub - fpdf-easytable/fpdf-easytable: fpdf-easyTable is a PHP class that makes it easy to build tables for PDF documents generated with the FPDF library[
^]
It is very easy to use:
$table=new easyTable($pdf, 3, 'border:1;');
$table->easyCell('Text 1', 'valign:T');
$table->easyCell('Text 2', 'bgcolor:#b3ccff;');
$table->easyCell('Text 3');
$table->printRow();
$table->rowStyle('min-height:20; align:{C}');
$table->easyCell('Text 4', 'colspan:3');
$table->printRow();
$table->endTable(4);
I hope my answer can help somebody.