gpt4 book ai didi

php - 根据变量值显示图像 PHP (FPDF)

转载 作者:行者123 更新时间:2023-11-30 21:35:42 24 4
gpt4 key购买 nike

我是新来的,一段时间以来我一直在寻找关于这个问题的答案,但我想不出解决这个问题的方法。

我的项目包含一个计算器,该计算器能够保存结果并让用户根据需要将其导出为 PDF 文件。现在,问题是,我想根据结果在 PDF 文件上展示图像:例如。如果结果是 M1,那么它会显示链接到 M1 的图像,依此类推。有什么办法吗?

我正在使用 PHP、MYSQL 数据库来保存结果和输入,以及 fPDF。任何帮助将不胜感激。谢谢。

    function Header(){

global $first;
global $second;
global $userinput;
global $client;
global $project;
global $obs;
global $vao;
global $perfil;
global $valuep; //this is the final result that needs to be linked to an image
global $lastname;
global $firstname;
global $lastname;
global $email;
global $address;
global $country;
global $state;
global $phone;
global $date;


// Select Arial bold 15
$this->AddFont('Raleway-Regular','','Raleway-Regular.php');
$this->AddFont('Raleway-Bold','','Raleway-Bold.php');
$this->SetFont('Raleway-Regular','',10);

$this->SetFont('Raleway-Bold','',10);
$this->Cell(22 ,5,'Name: ' . $firstname, '' .$lastname,0,0);
$this->Cell(20 ,5,'Email: ' . $email,0,1);
$this->Cell(20 ,5,'Phone: ' . $phone,0,1);
$this->Cell(20 ,5,'Website: ' . $state,0,1);



$this->Image('headerimage.jpg',160,15,30);

$this->Cell(100,0,'',0,0);
$this->Ln(5);

$this->SetFont('Raleway-Regular','',10);
$this->SetFillColor(0,0,0);
$this->SetDrawColor(255,255,255);


$this->Cell(25 ,5,"Project Name: " . $project ,0,1);
$this->Cell(24.5,5,'Client: ' .$client,1,0);
$this->Cell(25,5,'Date: ' . $date,0,1);

//

$this->Cell(0 ,5,'',0,1);


//

$this->Cell(190,0.3,'','T',0,'',true);

$this->Cell(0 ,5,'',0,1);


$this->SetFont('Raleway-Bold','',12);

$this->Cell(85 ,5,'Inputs ',0,0);
$this->Cell(25 ,5,'Span Details ',0,1);

$this->Cell(0 ,5,'',0,1);
$this->SetFont('Raleway-Regular','',11);
$this->Cell(190,0.3,'','T',0,'',true);
$this->Cell(0 ,5,'',0,1);
$this->Cell(25 ,5,'Name of Span: ' . $vao,0,0);

$this->Cell(0 ,5,'',0,1);
$this->Cell(0 ,5,'',0,1);
$this->Cell(85 ,5,'Wind Action: ' .$perfil . '' . $userinput . ' kN/m2]',0,0);

$this->SetFont('Raleway-Regular','',11);
$this->Cell(30 ,5,'Height: ' . $first . ' m',0,0);
$this->Cell(30 ,5,'Width: ' . $second . ' m',0,1);

//
$this->Cell(0 ,5,'',0,1);
//
$this->Cell(190,0.3,'','T',0,'',true);
$this->Cell(0 ,5,'',0,1);
$this->SetFont('Raleway-Regular','',11);
$this->SetFont('Raleway-Bold','',12);
$this->Cell(25 ,5,'Solution ',0,1);
$this->SetFont('Raleway-Regular','',11);
$this->Cell(0 ,5,'',0,1);
$this->Cell(190,0.3,'','T',0,'',true);
$this->Cell(0 ,5,'',0,1);

$this->Cell(25 ,5,'Final result: ' . $valuep,0,1); //image here next to the text
//
$this->Cell(0 ,5,'',0,1);
//

$this->Cell(0 ,5,'',0,1);
$this->Cell(0 ,5,'',0,1);
$this->Cell(0 ,5,'',0,1);

$this->SetFont('Raleway-Bold','',12);
$this->Cell(25 ,5,'Observations: ',0,1);
$this->SetFillColor(255,255,255);

}



function Footer(){


// Go to 1.5 cm from bottom
$this->SetY(-15);
// Select Arial italic 8
$this->SetFont('Raleway-Bold','',5);
// Print centered page number
$this->Cell(0,10,'Page '.$this->PageNo(),0,0,'C');
$this->Cell(25,5,"Vestibulum placerat lorem venenatis nulla tempor maximus a ut elit.",0,0,'R');
} }


$pdf = new PDF('P','mm','A4'); $pdf->AliasNbPages('{pages}');

$pdf->SetAutoPageBreak(true,5); $pdf->AddPage();


$pdf->SetFont('Raleway-Regular','',10); $text=str_repeat('' .$obs,1); $pdf->Write(5,$text); $pdf->SetDrawColor(255,255,255);



$pdf->Output();

最佳答案

这取决于您可能得到多少结果以及图片是否有所不同。

由于您使用的是 mySQL,我建议制作一个包含所有结果和图像的表格。

然后读出结果,瞧,你已经附上了图片。

关于php - 根据变量值显示图像 PHP (FPDF),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53957026/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com