$html="<html><head><title> Etiquettes </title> <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/> <style> </style> </head> <body>"; $html.="<table>"; foreach($repas_pdj as $pdj) { $html.="<tr>"; $html.="<td style='width:60mm;height:30mm;border:solid 1px blue;'>".$pdj->id."</td>"; $html.="<td style='width:60mm;height:30mm;border:solid 1px blue;'>".$pdj->id."</td>"; $html.="<td style='width:60mm;height:30mm;border:solid 1px blue;'>".$pdj->id."</td>"; $html.="</tr>"; // $html.="<span class='etq'>".$pdj->id."</span>"; } $html.="</table>"; $html.="</body></html>";
Hey friends, if some 1 know how can i increment every in this . **i want to get :
- 7313 – 7314 – 7315
- 7316 -7317 ….**
( am using dompdf laravel) ( i already triend to use just 1 in and i use (display:inline;) for but that doesn’t work with dompdf so i am trying this solution
Advertisement
Answer
if you want an object/id in each <td>
, just place only one <td>
per loop and place the <tr>
on conditions
$tdNumber = 0; foreach($repas_pdj as $pdj) { $tdNumber++; if ($tdNumber == 1) { $html.="<tr>"; } $html.="<td style='width:60mm;height:30mm;border:solid 1px blue;'>".$pdj->id."</td>"; if ($tdNumber == 3) { $html.="</tr>"; $tdNumber = 0; } } //this is to correctly close the table if ($tdNumber != 0) { for ($i=$tdNumber; $i<3; $i++) { $html.="<td style='width:60mm;height:30mm;border:solid 1px blue;'></td>"; } $html.="</tr>"; }