首页 > 解决方案 > 在 write() fpdf 中回显数据库

问题描述

$con = mysqli_connect("localhost","root","","final_osa");
$sel_query="SELECT * FROM ched_scholars WHERE id = '".$_GET['id']."';";
$result = mysqli_query($con,$sel_query);
while($row = mysqli_fetch_assoc($result)) {
$pdf->Write( 6, 'I, echo $row["student_name"];, of legal age and a resident of echo $row["present_address"]; understand that an Educational Scholarship/Financial Grants-in Aid has been awarded to me so that I may enroll in and complete the echo $row["course"];.' );
}

如何在 write() 中回显学生姓名?谢谢

标签: phpfpdf

解决方案


尝试在您的字符串中使用“{$var}”:

例如:

$myVar = "student";
$myString = "The {$myVar} are good.";

在你的情况下:

$con = mysqli_connect("localhost","root","","final_osa");
$sel_query="SELECT * FROM ched_scholars WHERE id = '".$_GET['id']."';";
$result = mysqli_query($con,$sel_query);
while($row = mysqli_fetch_assoc($result)) {
$pdf->Write( 6, 'I, {$row["student_name"]}, of legal age and a resident of {$row["present_address"]} understand that an Educational Scholarship/Financial Grants-in Aid has been awarded to me so that I may enroll in and complete the {$row["course"]}.' );
}

推荐阅读