PHP portfolio piece – Analytics data.

I recently published a blog post about a portfolio project I am developing using the LAMP stack, Bootstrap 4, jQuery, and the MVC (Model-View-Controller) design pattern in core PHP. In this post, I will introduce an additional feature I integrated into the existing project.

computer code on dark screen
Image by xresch from Pixabay

If you enjoy the content written here, by all means, share this blog and your favorite post(s) with others who may benefit from or like it as well. Since coffee is my favorite drink, you can even buy me one if you would like!

I keep tabs on walking data via a pedometer mobile application for the many walks I take as I work towards better health and manageable weight. Analytics are vital in understanding patterns in your data. Utilizing MySQL VIEW‘s along with the Aggregate functions SUM() and AVG(), I broke down the analytic data into these broad categories:

  • The shoe worn (Totally irrelevant. I just happen to have purchased, worn, and tried a lot of different hiking shoes/boots)
  • The day of the week (E.g., Monday, Tuesday, etc…)
  • The month
  • The year

I further subdivided the categories – with the exception of ‘yearly’ data – into 2 similar sub-groups: sums and averages. I added in an Analytics button between the Export CSV and Add A Walk buttons on the ‘All Walks’ page:

jQuery Datatables buttons
‘Analytics’ button.

Clicking Analytics opens this page of Bootstrap 4 tabs:

Bootstrap 4 tabs
Using Bootstrap 4 tabs looking at the default tab view.

Notice for each category (Shoes, Monthly, and Weekday) there is an ‘Averages’ and ‘Totals’ tab. Following are several screen-shots of the various data provided by these tabs:

Dynamic Bootstrap 4 table with PHP
Monthly Totals tab using Bootstrap 4 and PHP.

Bootstrap 4 dynamic table with PHP in a tab
Weekday Averages tab.

Bootstrap 4 tabs
Yearly Stats tab with Bootstrap 4 and dynamic PHP.

Goals and Improvements

My original intent was to provide each tab’s table with the necessary data using a dynamic jQuery DataTable, utilizing AJAX, and server-side processing. However, at the time of this writing, I used passing the retrieved MySQL data to the view from the applicable controller as is common in the MVC architecture. Each tab’s Bootstrap 4 table is still dynamic but does not use the jQuery DataTable with AJAX so I hope to integrate that functionality in the future.

As always, if you have any questions or comments about the post, feel free to leave them in the comments section below.

Like what you have read? See anything incorrect? Please comment below and thank you for reading!!!

A Call To Action!

Thank you for taking the time to read this post. I truly hope you discovered something interesting and enlightening. Please share your findings here, with someone else you know who would get the same value out of it as well.

Visit the Portfolio-Projects page to see blog post/technical writing I have completed for clients.

To receive email notifications (Never Spam) from this blog (“Digital Owl’s Prose”) for the latest blog posts as they are published, please subscribe (of your own volition) by clicking the β€˜Click To Subscribe!’ button in the sidebar on the homepage! (Feel free at any time to review the Digital Owl’s Prose Privacy Policy Page for any questions you may have about: email updates, opt-in, opt-out, contact forms, etc…)

Be sure and visit the “Best Of” page for a collection of my best blog posts.

Josh Otwell has a passion to study and grow as a SQL Developer and blogger. Other favorite activities find him with his nose buried in a good book, article, or the Linux command line. Among those, he shares a love of tabletop RPG games, reading fantasy novels, and spending time with his wife and two daughters.

Disclaimer: The examples presented in this post are hypothetical ideas of how to achieve similar types of results. They are not the utmost best solution(s). The majority, if not all, of the examples provided, are performed on a personal development/learning workstation-environment and should not be considered production quality or ready. Your particular goals and needs may vary. Use those practices that best benefit your needs and goals. Opinions are my own.

Hey thanks for commenting! Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.