2016-09-08 8 views
0

リファレンス - http://i.stack.imgur.com/oAIbz.pngtcpdfに一意の値を表示する方法は?

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); 

`

+0

に、私たちは、私はそれが一度に見えるようにする方法を知っていること、私は列に同じ生徒の名前を持っているあなたの件名行 – nogad

+0

よりも説明の多くを必要としますか? –

+0

すべてのアイデア?データから私は2つの料金で学生名を持っていますが、私はtcpdfで一度表示したいと思います。 –

答えて

0

私はループのいくつかの種類にあなたを思いますか?あなたが名前を使用しているという事実を保存する必要があり、ループチェックの残りのためにあなたがループ

$name_used=FALSE;//default to false 

外に再び

それを表示する必要があるかどうかを判断するために名前を使用している場合その後、あなたのループ

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 
} 
+0

私は試しましたが、 。それ以上の提案? –

+0

@BullStarkを編集しました。ループの外側に最初の行を配置すると言っています – nogad

関連する問題