Web Development Assignment: Database Connections
Create a MySQL or MariaDB database on your web host named your first name and last name. Most web hosts use PHPMyAdmin, a tool used to manage MySQL databases. See your web host's documentation / support site to determine how to create a MySQL database on your specific web host. You will also need to create a username and password to allow you to access the database from your PHP script using mysqli_connect().
Exclude any spaces; use one word such as "yourfirstnameyourlastname." Create a table named "comments." In the "comments" table, create the fields ID, name, title, comments, and comment date. Use the proper field types and allow comments to be over 100 characters. Comment date should be a timestamp field that is automatically updated with the current timestamp when a new record is inserted into the table. ID should be the primary key and auto increment.
Develop a PHP connection script that successfully connects to your database. It should use the MySQL_error() or MySQLi_error() function appropriately to test whether a successful connection exists.
Note, some web hosts may be using the new MySQL functions. Thus, you may notice the "I" placed in front of the latter function. You need to determine if your webhost requires new MySQL functions to work. For example, to connect to MySQL you may need to use:
mysqli_connect()
or
mysql_connect()
The textbook may use older functions and you can use the new versions by placing an "I" after "mysql" - mysqli_query().
Create a comments section on your family/friend/pet tree that is database driven. Upon successful authentication to the tree page, a user should be given a new link to a new form. The form should have a name, title, and a comment field. Proper form validation should exist.
Upon form submission, the name, title, and comment data should be inserted into the associated fields in the comments database table on your web host.
Write a SQL select statement against the comments table in your database and display each row properly formatted on the main tree page. The most recent comment should be displayed first. All user comments should display under the tree like:
Name of the person who made the comment
Title
Date
Comments
Write update and delete SQL statements that allow comments to be updated and removed from the tree. Upon completion, comments can be added, updated, and removed from the database via the family tree web page.