Vous avez juste besoin d'un simple compteur de bouclage :
$tbl = '';
$counter = 0;
// foreach item in your array...
$counter++;
if ($counter > 9) {
$pdf->AddPage();
$counter = 0;
}
$tbl .= '
Edit :vous voulez probablement refactoriser la façon dont vous bouclez, mais comme vous l'avez écrit maintenant, la solution est la suivante :
$result = mysqli_query($con,"SELECT * FROM b_sale_basket WHERE ORDER_ID=$ID ORDER BY PRICE * QUANTITY DESC");
$total=0;
$counter = 0; //implement a counter
while($row = mysqli_fetch_array($result))
{
$counter++; //increment the counter on each loop
$quantity = $row['QUANTITY'];
$description = $row['NAME'];
$unitprice = $row['PRICE'];
$lineprice = $row['PRICE']*$row['QUANTITY'];
$total=$total+$lineprice;
$tbl_header = '<table style="width: 650px;" cellspacing="0" cellpadding="5">';
$tbl_footer = '</table>';
$tbl = '';
$tbl .= '
<tr>
<td style="width: 50px; text-align: left; border-bottom: 0.1em solid #808080;"><p style="color:#808080;">'.number_format($quantity,0).'</p></td>
<td style="width: 350px; border-bottom: 0.1em solid #808080;"><p style="color:#808080;">'.$description.'</p></td>
<td style="width: 125px; text-align:right; border-bottom: 0.1em solid #808080;"><p style="color:#808080;">'.number_format($unitprice,2).'</p></td>
<td style="width: 125px; text-align:right; border-bottom: 0.1em solid #808080;" align="right" ><p style="color:#808080;">'.number_format($lineprice,2).'</p></td>
</tr>
';
if ($counter > 9) {
$pdf->AddPage();
$counter = 0;
}
$pdf->writeHTML($tbl_header . $tbl . $tbl_footer, true, false, false, false, '');