How to print a table on while loop to get data from database using Dompdf?
Below are my codes that I have done but with fail result.
$html = '<table>
<tr>
<td>Date</td><td>Name</td>
</tr>';
// Query from mysql
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
$date = $row['date '];
$name = $row['name'];
$html . = '<tr>
<td> ' . $date . ' </td>' . $name . '</td>
</tr>';
}
}
$html .= '</table>';
require('../dompdf/autoload.inc.php');
use Dompdf\Dompdf;
$dompdf = new Dompdf();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("Result.pdf",array("Attachment"=>0));
$dompdf->clear();