Blog 17 – Website finishing touches

In Blog 15 – Website continued I got the base of the site working with the features needed to demonstrate the system. All I need to do is set up an example class under with a timeframe that I am going to swipe a card over the arduino unit, and it will show in the attendance records. I mentioned that I wanted to add an ability to adjust the attendance records manually. I also wanted to add a way to download CSV files. This would contain a copy of the attendance records for the class. Below I go over how they work.


At the bottom of the attendance page I added a download CSV button.29-10-csv-button Since only one MySQLi query can be called per page and to get the information to go in the CSV file and it requires a MySQLi query, I created another PHP file to perform this task. As I had no clue on how to approach this I googled it. I came across this post “Query mysql and export data as CSV in PHP“. The second code suggestion was the solution I ended up using. It starts out by getting the data from the database and putting it into a array. If that is successful, the PHP tells the file some html commands to make it a temporary page and to create a CSV file that is to be downloaded. The data stored in the array is then inserted into the file before it is downloaded.

When the file is opened it contains the attendance details of the class.


Ive also added a Submit button. This is for the saving of any changes made by the teacher. When they click the button it takes posts the form, including the table and its cells, to the attendance save file. The PHP in this then works through each row of the table and updates the attendance table if there are any changes made by the teacher. To make this I used the example posted to “how to insert html table data into mysqli database in single command“.  I have made the file redirect the teacher back to the home page. This give means that the teacher has to go back into the attendance. I have done this so the table has a chance to update.


I am continuing to make little changes to the code to improve the site so it is subject to change. The code posted below is accurate as of 28/10/2016.


Current Final Version of the code as of 28/10/2016. I have *** out any sensitive code.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s