Monday, July 16, 2018

Web Programming projects

I am currently taking a web programming course and have already worked quite a bit with PHP and MySQL.  One of my major assignments required a student information table to be modified and the table of students to be displayed.   This course has been good for broadening my skills as more applications become web-based. 

Setting up the initial student table
First I used a SQL script to fill out the initial student table.  This was done through XAMPP and phpMyAdmin.


Student information displayed in HTML table using PHP
 After setting up the table, I needed to write a PHP script to display the contents of the MySQL student table.  This table also used CSS to style the table headings to be gray with bold text, the ID column to be italicized, and the other cells to be standard format with white background and black text.
The form for modifying the student table

The output after deleting student with ID of 1
The first action was to delete a user.  This action was detected if the ID for the student to be deleted is filled.  A MySQL query was generated with the POST data in PHP to delete the user before displaying the updated student table.
Form filled out to add a new student

Table updated to show the additional student
  Action #2 was to add a new user to the student table.  This action was detected if at least ID data was filled out in the student-add part of the input form, and the delete ID was empty.  Some text was shown at the top of the page to say what action is performed and also showed the POST data sent to the PHP file.  This post data was then used to form a MySQL query to add the student to the table if they had a valid ID.
Form filled out for updating student information

Table updated to reflect updated student #7
The third and final action was to update an existing student's information.  In order for this action to be detected, ID's for both deletion and addition had to be blank and the ID for update had to be full.  Only the posted text inputs that were full would be used in creating the update query, meaning one could opt to leave some fields unchanged.

While not the most advanced project, I thought I learned a lot from it.   It would be very helpful for creating webpages with dynamic input.  MySQL and PHP are not too hard to use, but they can be quite powerful for making a data-driven website.  Up to this class, my experience with web programming was only static HTML pages with a small foray into CSS.  I think this course is making me a more complete programmer.