简体   繁体   English

如何在tcpdf上显示唯一值?

[英]How to show unique value on tcpdf?

Reference - http://i.stack.imgur.com/oAIbz.png 参考-http://i.stack.imgur.com/oAIbz.png

foreach($data as $k=>$v){
//print_r($v);
exit;    
if ($yr != $v['year']) {
$pdf->SetFont('helvetica', 'B',9);
$pdf->Cell(25,4, 'Payment Year :',0,0,'L', false,'',0,false,'T','M');
$pdf->SetFont('helvetica', '',9);
$pdf->Cell(10,4, $v['year'],0,1,'L', false,'',0,false,'T','M');

//header
$pdf->SetFont('helvetica', 'B',9);
$pdf->Cell(67,4, 'Student',1,0,'C', false,'',0,false,'T','M');
$pdf->Cell(30,4, $v['year'].' Class',1,0,'C', false,'',0,false,'T','M');
$pdf->Cell(47,4, 'Fee',1,0,'C', false,'',0,false,'T','M');
$pdf->Cell(20,4, 'Amount',1,0,'C', false,'',0,false,'T','M');
$pdf->Cell(20,4, 'Total',1,1,'C', false,'',0,false,'T','M');
$pdf->SetFont('helvetica', '',9);       

//$total1 = $total1 + $v['amount'];
$total1 = 0;
 $yr = $v['year'];    
}  

$pdf->MultiCell(67, 4,  $v['student_name'], 1, 'L', 0, 0, '', '', true, 0, false, true, 8, 'T', false);
$pdf->MultiCell(30, 4,  $v['class_english_name'], 1, 'L', 0, 0, '', '', true, 0, false, true, 8, 'T', false); 
$pdf->MultiCell(47, 4,  $v['fee_group_desc'], 1, 'L', 0, 0, '', '', true, 0, false, true, 8, 'T', false);
$pdf->MultiCell(20, 4,  '*'.number_format($v['amount'],2), 1, 'C', 0, 0, '', '', true, 0, false, true, 8, 'T', false);  
$total1 = $total1 + $v['amount'];
$total2 = $total2 + $v['amount'];
$pdf->MultiCell(20, 4,  number_format($total1,2), 1, 'C', 0, 1, '', '', true, 0, false, true, 8, 'T', false);

` `

i guess your in some kind of loop? 我猜你在某种循环中? you need to store the fact that you have used the name, and for the rest of the loop check if you have used the name to determine if you need to display it again 您需要存储使用名称的事实,并在循环的其余部分中检查是否使用名称来确定是否需要再次显示名称

outside the loop 循环外

$name_used=FALSE;//default to false

then in your loop 然后在你的循环

if(!$name_used){

$pdf->MultiCell(67, 4,  $v['student_name'], 1, 'L', 0, 0, '', '', true, 0, false, true, 8, 'T', false);
$name_used=TRUE;//after first time through loop make this true, so name not used again    
}else{
//maybe noting, maybe a blank cell
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM