2017-03-15 13 views
1

私は名前がデータベーステーブルから受け取った:StructurizeマルチセルFPDF内部

私は multicellを使用して、その内部にFPDFのようなPDFファイルとプリントの名前を作成したい
ADEEB (staff) , ALISTER (staff), AMER (staff), AMIRABUBAKAR (staff), AMIRULHAFIZ (staff), 
ANA (staff), ANDIKA (staff), ANDREW (staff), ARINA (staff), DIANADEWI (staff), DINA (staff), 
DINIE (staff), DUDU (staff), DUNCAN (staff), ELIZABETH (staff), ERIC (staff), ERIN (staff), 
FAUZE(staff), FAZLY (staff),FELIZ (staff), HAYKAL (staff), IVANPINTO (staff), IVORY (staff), 
IVY (staff) 

:また

function Mach($header, $header1, $lbl3) 
{ 
    $this->Line(10,$this->GetY(),200,$this->GetY()); 
    //Times 12 
    $this->SetFont('Times','B',12); 
    //Background color 
    $this->SetFillColor(255,255,255); 
    //Title 
    $this->Cell(50,10,"$header1",0,1,'L'); 
    $this->SetFont('Times','',12); 
    $this->MultiCell(185,10,"$lbl3",1,1,'L'); 

} 

$con = mysqli_connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_NAME); 
$pdf = new PDF(); 
$pdf->AliasNbPages(); 
$pdf->AddPage(); 
for($y=0;$y<$len;$y++) 
{ 
    $column_procStaff = ''; 

    $result6 = getProcessStaff($projectNo,$proc[$y]); 
     if (!$result6) { 
      die('Invalid query: ' . mysqli_error($con)); 
     } 
     $c=0; 
     while($row6 = mysqli_fetch_array($result6)) 
     { 
      $procStaff = $row6['proc_staff']; 
      if($c==0) 
      { 
       $column_procStaff .= $procStaff." (staff) "; 
      } 
      else 
      { 
       $column_procStaff .= ", ".$procStaff." (staff)"; 
      } 
      $c++; 
     }  
    $pdf->Mach("Process Name: $proc[$y]", $column_procStaff); 
} 

私は構造が受信したいです名前。このようななめらかに表示するためにそれを行うにはどのような方法があります:

ここ
ADEEB (staff),   ALISTER (staff),   AMER (staff), 
AMIRABUBAKAR (staff), AMIRULHAFIZ (staff),  ANA (staff), 
ANDIKA (staff),   ANDREW (staff),    ARINA (staff), 
DIANADEWI (staff),  DINA (staff),    DINIE (staff), 
DUDU (staff),   DUNCAN (staff),    ELIZABETH (staff), 
ERIC (staff),   ERIN (staff),    FAUZE(staff), 
FAZLY (staff),   FELIZ (staff),    HAYKAL (staff), 
IVANPINTO (staff),  IVORY (staff),    IVY (staff) 

答えて

2

は、あなたが望むように名前を書くためにFPDFを使用して、スニペットです:

// Your data 
$names= array("ADEEB (staff)", "ALISTER (staff)" ,"AMER (staff)" ,"AMIRABUBAKAR (staff)" ,"AMIRULHAFIZ (staff)", "ANA (staff)" ,"ANDIKA (staff)" ,"ANDREW (staff)" ,"ARINA (staff)" ,"DIANADEWI (staff)" ,"DINA (staff)", "DINIE (staff)" ,"DUDU (staff)" ,"DUNCAN (staff)" ,"ELIZABETH (staff)" ,"ERIC (staff)" ,"ERIN (staff)", "FAUZE(staff)" ,"FAZLY (staff),FELIZ (staff)" ,"HAYKAL (staff)" ,"IVANPINTO (staff)" ,"IVORY (staff)", "IVY (staff)"); 
// Number of column wanted 
$nbColumn = 3; 

// Computing width of columns 
$maxWidth = 0; 
foreach ($names as $n){ 
    $w = $pdf->GetStringWidth($n); 
    if($maxWidth<$w){ 
     $maxWidth=$w; 
    } 
} 
// add Margin 
$maxWidth = $maxWidth + 10; 

foreach ($names as $index => $n){ 
    // width, height, text, no norder, going to next line 
    $pdf->Cell($maxWidth, 5, $n, 0, $index%$nbColumn==$nbColumn-1); 
}