我正在使用FPDF生成報告到PDF文件,它的工作,但我想要的是打印名稱從變量報告的標題可以任何機構告訴我如何做到這一點FPDF生成的PDF顯示標題文本
我印在標題變量是生成報告我嘗試這樣,但它不工作
<?php
$username=$_POST['username'];
function Header()
{
$name="Export PDF";
$this->SetFont('Arial','B',10);
$this->Image('images/pdflogo.png', 5,5,60);
$this->Image('images/hr1.jpg', 10,25,190);
$this->Text(100,25,'Weekly Report for user'.$username);
$this->Cell(80);
$this->SetFont('Arial','B',9);
$this->Ln(20);
}
編輯者的用戶名:完整的代碼下面
class PDF extends FPDF {
function Header() {
$name = "Export PDF";
$this->SetFont('Arial', 'B', 10);
$this->Image('images/pdflogo.png', 5, 5, 60);
$this->Image('images/hr1.jpg', 10, 25, 190);
$this->Text(100, 25, 'Weekly Report'.$username);
$this->Cell(80);
$this->SetFont('Arial', 'B', 9);
$this->Ln(20);
}
function Footer() {
$this->Image('images/hr1.jpg', 10, 280, 190);
}
function LoadData($file) {
$lines = file($file);
$data = array();
foreach ($lines as $line) {
$data[ ] = explode(';', chop($line));
}
return $data;
}
function BasicTable($header, $data) {
$this->SetFillColor(255, 255, 255);
$this->SetDrawColor(0, 0, 0);
$w = array(20, 30, 25, 23, 30, 30, 30, 12, 30);
for ($i = 0; $i < count($header); $i++) {
$this->Cell($w[ $i ], 7, $header[ $i ], 1, 0, 'C', true);
}
$this->Ln();
foreach ($data as $eachResult) { //width
$this->Cell(20, 6, $eachResult[ "issue_title" ], 1);
$this->Cell(30, 6, $eachResult[ "department" ], 1);
$this->Cell(25, 6, $eachResult[ "submitted_by" ], 1);
$this->Cell(23, 6, $eachResult[ "date" ], 1);
$this->Cell(30, 6, $eachResult[ "solution_g" ], 1);
$this->Cell(30, 6, $eachResult[ "t_status" ], 1);
$this->Cell(30, 6, $eachResult[ "date_solved" ], 1);
$this->Ln();
}
}
}
$pdf = new PDF();
$header = array(
'Issue Title',
'Department',
'Submited By',
'Date',
'Solution Given',
'Ticket Status',
'Date of Solved'
);
//Data loading
//*** Load MySQL Data ***//
$objConnect = mysql_connect("localhost", "root", "") or die("Error:Please check your database username & password");
$objDB = mysql_select_db("helpdesk_ticket");
$strSQL = "SELECT issue_title, department,submitted_by,date,solution_g,t_status,date_solved FROM allocated_task where assigned_user ='$assigned_user' and date >= '$fyear-$fmonth-$fday' AND date <= '$tyear-$tmonth-$tday' ";
$objQuery = mysql_query($strSQL);
$resultData = array();
for ($i = 0; $i < mysql_num_rows($objQuery); $i++) {
$result = mysql_fetch_array($objQuery);
array_push($resultData, $result);
}
//************************//
function forme() {
}
$pdf->SetFont('Arial', '', 6);
//*** Table 1 ***//
$pdf->AddPage();
//$pdf->Image('images/pdflogo.png',20,8,83);
//$pdf->Ln(15);
$pdf->BasicTable($header, $resultData);
forme();
$pdf->Output("$d.pdf", "F");
$rep_count = mysql_query($strSQL);
$con = mysql_num_rows($rep_count);
我使用FPDF類來生成PDF – user3355995