0

enter image description here

$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

Youssef MK
  • 21
  • 2
  • What do you mean, _"increment my result"_? This does not appear to be an arbitrary counter, but an ID coming from your `$pdj` objects - so what sense would "increasing" those values make? Are you perhaps _actually_ trying to ask, how you can output three of these objects per table row ...? https://stackoverflow.com/questions/8385165/display-3-items-per-row-while-loop-php-mysql – CBroe Nov 01 '21 at 09:38

1 Answers1

-1

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>";
}
N69S
  • 16,110
  • 3
  • 22
  • 36