我需要使用来自mysql数据库的php和fpdf在pdf上显示图像,
有点新的与php友好协助 .
最后一部分是将图像提取到pdf请参阅下面的代码 .
<?php
include_once("connection.php");
$sql = "SELECT id as profile_ID,name,gender,age,marital FROM profile p where id = 9";
$resultset = mysqli_query($db, $sql) or die("database error:". mysqli_error($db));
require('fpdf/fpdf.php');
//require('mem_image/mem_image.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',12);
$pdf->Cell(100, 16, "profile");
$pdf->Ln();
while ($field_info = mysqli_fetch_field($resultset)) {
$pdf->Cell(30,6,$field_info->name,1);
}
while($rows = mysqli_fetch_assoc($resultset))
{
$pdf->SetFont('Arial','',12);
$pdf->Ln();
foreach($rows as $column) {
$pdf->Cell(30,6,$column,1);
}
}
$pdf->Ln();
$pdf->Ln();
$pdf->Ln();
$pdf->Ln();
$sql = "SELECT id as relative_id, trg as profile_id, Name, social as social_media FROM relatives r" ;
$resultset = mysqli_query($db, $sql) or die("database error:". mysqli_error($db));
$pdf->SetFont('Arial','B',12);
$pdf->Cell(100, 16, "Relatives");
$pdf->Ln();
while ($field_info = mysqli_fetch_field($resultset)) {
$pdf->Cell(30,6,$field_info->name,1);
}
while($rows = mysqli_fetch_assoc($resultset))
{
$pdf->SetFont('Arial','',12);
$pdf->Ln();
foreach($rows as $column) {
$pdf->Cell(30,6,$column,1);
}
}
$pdf->Ln();
//将图像提取到pdf $ sql =“SELECT文件FROM tbl_uploads t其中id = 1”; $ resultsset = mysqli_query($ db,$ sql)或die(“数据库错误:” . mysqli_error($ db));
while ($row = mysqli_fetch_assoc($resultset)) {
// Get the image from each row
$url = $row['url'];
// Place the image in the pdf document
$pdf->Image($url);
$pdf->MemImage($image, 50, 30);
}
$pdf->Output('Profile.pdf','i');
?>