Book Image

Building a Web Application with PHP and MariaDB: A Reference Guide

By : Sai S Sriparasa
Book Image

Building a Web Application with PHP and MariaDB: A Reference Guide

By: Sai S Sriparasa

Overview of this book

Table of Contents (17 chapters)
Building a Web Application with PHP and MariaDB: A Reference Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Data exports


Now that we have successfully imported data into our database, let's look at the process for exporting the data. In this section, we will look at two tasks: exporting the data to a file in the local filesystem and allowing a user to download that exported file. Let's begin by making a small change to the get.php view to add a link to export the data, using the following code. We will add the following line of code to the paragraph tag that contains the Import Students link:

<a id="exportStudentsLink" href="export">Export Students</a>

Here, we set the href attribute to the export action that we will be adding. As the name suggests, we will use the export action to export the student data into a CSV file, and allow the users to download this data. Before we go over the export action, we need to make three updates to the existing code. The first change will be to add a constant that will hold the root-working directory to our config.php file that houses our configurations...