Reputation: 408
I am creating a pdf which is working but the values are not being entered into the multicell of the pdf.
Lets take the date for example, the user enters a date and on the PDF it should look like:
Date: 26/01/2017
but this is what it looks like now:
Date:
Below is my code with the date example:
<?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');
Upvotes: 0
Views: 867
Reputation: 10356
According to the fpdf manual:
MultiCell(float w, float h, string txt [, mixed border [, string align [, boolean fill]]])
While in your code:
$pdf->MultiCell(190, 10, $questionDate, $date, 'C')
;
So $date
isn't part of the txt parameter to appear in the cell.
Instead, you need to append the $date variable to the $questionDate one.
$pdf->MultiCell(190, 10, $questionDate . $date, 'C')
;
Upvotes: 2