Reputation: 1571
How can I set fill parameter to a certain row and col? Anyhelp? $fill is the variable I used, any ideas?
$row = 10;
$col = 10;
$w = 8;
$h = 8;
for ($r=1;$r<=$row;$r++)
{
for ($c=1;$c<=$col;$c++)
{
$pdf->Cell($w,$h, 'STRING' ,1,0,'C',$fill);
}
$pdf->Ln();
}
Upvotes: 2
Views: 5736
Reputation: 2713
You cand do it using your row count and module operation like:
$row = 10;
$col = 10;
$w =8;
$h=8;
for ($r=1;$r<=$row;$r++)
{
if($r%2==0) { //here you can change your logic
$fill = "#F0F0F0";
} else {
$fill = "#FFFFFF";
}
for ($c=1;$c<=$col;$c++)
{
$pdf->Cell($w,$h, 'STRING' ,1,0,'C',$fill);
}
$pdf->Ln();
}
Upvotes: 3