Search code examples
phpfpdf

echo database in 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"];.' );
}

how can I echo the student name inside the write()? thanks


Solution

  • Try use "{$var}" inside your string:

    For example:

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

    In your case:

    $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"]}.' );
    }