2017-01-30 44 views
0

我创建这是工作的一个PDF格式,但值不被输入到PDF格式的多细胞。FPDF多小区没有显示值

让我们例如日期,用户输入一个日期上的PDF它应该看起来像:

Date: 26/01/2017 

,但是这是它看起来像现在:

Date: 

下面是我的代码,日期例如:

<?php 
//set the question values 
$questions  = array(
'name' => "Name: ", 
'date' => "Date: ", 
'first' => "First Day of Leave: ", 
'last' => "Last Day of Leave: ", 
'days' => "Number of Days Taken: ", 
'email' => "Managers Email: ", 
'creditdays' => "Leave Days in Credit", 
'personnel' => "THIS SECTION TO BE COMPLETED BY PERSONNEL DEPARTMENT", 
'credit' => "Leave Days in Credit:", 
'mansign' => "Signed:", 
'date2' => "Date:", 
'authorise' => "Authorised By:", 
'date3' => "Date:", 
'auth' => "Authorisation Of Leave" 
); 
//set the question answers 
$date   = $_POST['date']; 
$first   = $_POST['first']; 
$last   = $_POST['last']; 
$days   = $_POST['days']; 
$email   = $_POST['email']; 
$name   = $_POST['name']; 
//set the question names 
$questionName = $questions['name']; 
$questionDate = $questions['date']; 
$questionFirst = $questions['first']; 
$questionLast = $questions['last']; 
$questionDays = $questions['days']; 
$questionEmail = $questions['email']; 
$personnel = $questions['personnel']; 
$credit = $questions['credit']; 
$mansign = $questions['mansign']; 
$date2 = $questions['date2']; 
$authorise = $questions['authorise']; 
$date3 = $questions['date3']; 
$auth = $questions['auth']; 
//Create the PDF 

require('fpdf.php'); 
$pdf = new FPDF(); 
$pdf->AddPage(); 

$pdf->SetFont('Arial', 'B', 16); 
//insert fields 
$pdf->SetDrawColor(100, 100, 100); 
$pdf->SetFillColor(100,100,100); 
$pdf->Multicell(200, 3, "Leave Application Form", "", 'C'); 
$pdf->Ln(); 
$pdf->Ln(); 
$pdf->MultiCell(190, 10, $questionDate, $date, 'C'); 
+0

$ questionDate。 $日期(不是逗号)[看到我的回答更好理解] –

回答

2

按照fpdf manual

MultiCell(float w, float h, string txt [, mixed border [, string align [, boolean fill]]]) 

虽然在你的代码:

$pdf->MultiCell(190, 10, $questionDate, $date, 'C');

因此$date不是txt参数出现在单元格中的一部分。 相反,你需要将$ date变量追加到$ questionDate之一。

$pdf->MultiCell(190, 10, $questionDate . $date, 'C');

+0

工作!但是现在我的队列“C”并不是一直向左对齐? – RedZ

+0

因为你首先需要通过后,才以“对齐”参数“边框”参数和值。 –

+0

如果我的答案帮助你请注意,批准它。谢谢。 –