1

I recently started to use FPDF as a solution to export some data from sql to pdf. This is my attempt to display a while loop. The only problem is with the line break at the end.

$sql = "SELECT * FROM table ORDER BY ID ASC";
$items = mysql_query($sql);
while ($get = mysql_fetch_array($items)):

    $pdf->SetXY (10,130);
    $pdf->SetFontSize(12);
    $txt="<b>Item 1</b>: $get[NAME]";
    $pdf->WriteHTML(utf8_decode($txt));

    $pdf->SetXY (10,135);
    $pdf->SetFontSize(12);
    $txt="<b>Item 2</b>: $get[CITY]";
    $pdf->WriteHTML(utf8_decode($txt));

    $pdf->Ln(30);
endwhile;

Any solution to separate the result with some space?

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
Adrian
  • 159
  • 7
  • Have you tried PHP_EOL? – Fawzan Aug 09 '17 at 08:47
  • No. Can you tell me moe about this? – Adrian Aug 09 '17 at 08:48
  • 1
    Every time you use [the `mysql_`](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) database extension in new code **[this happens](https://media.giphy.com/media/kg9t6wEQKV7u8/giphy.gif)** it is deprecated and has been for years and is gone for ever in PHP7. If you are just learning PHP, spend your energies learning the `PDO` or `mysqli` database extensions and prepared statements. [Start here](http://php.net/manual/en/book.pdo.php) – RiggsFolly Aug 09 '17 at 08:51
  • you can you `/n/r` to use new line new row – perumal N Aug 09 '17 at 08:53

0 Answers0