From the course: PHP: Exporting Data to Files
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Outputting the database result as a .odt file - PHP Tutorial
From the course: PHP: Exporting Data to Files
Outputting the database result as a .odt file
Now that we've created the template, and converted its main content file into an XSLT style sheet, we can use the OpenDoc class to generate and download an Open Document Text file. So make sure that you've got the OpenDoc class definition in your testing site. The class expects an XML string, so we'll also use the XML class to convert the database result. That means you need both Xml and Base.php in your testing site. You also need the Psr4Autoloader. This is flowers_odt.php. We'll use this file to create the download. The code at the top of the page includes the auto loader and then registers the foundation PHP namespace. Lines eight and nine import the XML and OpenDoc classes with the use operator, and line 11 includes the database result. I'm using the PDO version. If you're using MySQL, change PDO to mySQLI. All the code needs to go inside the triblock beginning on line 14. In the previous chapter we used the XML class to save a file to disc, and create a download file. This time,…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
(Locked)
Creating a .odt file to use as a template4m 29s
-
(Locked)
Inspecting the structure of an OpenDocument text file2m 43s
-
(Locked)
Extracting the main content file from a .odt document5m 2s
-
(Locked)
Converting the main content file to XSLT8m 3s
-
(Locked)
Outputting the database result as a .odt file7m
-
(Locked)
-
-