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.

Offering a choice of download formats

Offering a choice of download formats - PHP Tutorial

From the course: PHP: Exporting Data to Files

Start my 1-month free trial

Offering a choice of download formats

Throughout this course, we've always concentrated on exporting to a specific format. This is usually sufficient because Microsoft Office, Open Office and Libra Office, all use variations of open document format, so spreadsheets and text files are generally interoperable. They can also open CSV, plain text, and RTF files. But offering users a choice, is easy with PHP. I've opened flowers_choice.php, which you can find in the Exercise Files for this video. It's the same as flowers_word.php with the addition of a Select menu at the bottom of the HTML. So if we scroll down to the bottom, There is the select menu. It has the name format, and two options, Ms Word, and opendoc. So, all that's necessary to offer users a choice of download format, is to create a conditional statement in the code that processes the download. So let's go back to that code. We're going to be creating an ODT file as well as a Word file. So, we need to import the OpenDoc class. So, add a new line after line nine…

Contents