From the course: PHP: Exporting Data to Files

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Adding the data and outputting a .rtf file

Adding the data and outputting a .rtf file - PHP Tutorial

From the course: PHP: Exporting Data to Files

Start my 1-month free trial

Adding the data and outputting a .rtf file

We've added the main heading to our rich text format document. Now, we need to create a loop to add the database results to the document, and output it as an RTF file. So, at the end of the tri-block after the main heading that we've just added. We'll add a while loop, to query the database. And we'll store each row in row. And use the getRow function that was defined in chapter one. This works with both PDO and with MySQLi. And pass it, our database result, which is stored as result. Inside the loop, we need to use the PHPRtfLite WriteText Method, to add each element in the database result to the current section of the document. The first element that we'll use, is the make of the car. This will be our subheading. We're adding it to the section, so section, right text. The first argument will be, the make element from R row. Then we need the font, which is font H two, and then the format for it, which is format H two. To prevent a page break occurring immediately after an element…

Contents