1
$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

Cœur
  • 37,241
  • 25
  • 195
  • 267
1437
  • 13
  • 4
  • it wont print the student name. it prints this one "$row["student_name"];" – 1437 May 03 '18 at 19:53
  • 3
    You cannot echo like that in a string you need to concat it. `'string' . $var . 'more string'` – nerdlyist May 03 '18 at 19:54
  • Possible duplicate of [What is the difference between single-quoted and double-quoted strings in PHP?](https://stackoverflow.com/questions/3446216/what-is-the-difference-between-single-quoted-and-double-quoted-strings-in-php) – ficuscr May 03 '18 at 19:58
  • thanks i've finally made it hehe appreciate your help. i used concat – 1437 May 03 '18 at 20:06
  • Yep, looks like that'll work now. – Malovich May 03 '18 at 20:09
  • I've rollbacked your inclusion of the solution in the question itself (you may find it in the revision history). Instead, please post it as its own answer, thank you. – Cœur Jul 01 '18 at 14:49

1 Answers1

2

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