From afc8c9065fc45e0b5d39f5e48f0d14f81f3ccbb9 Mon Sep 17 00:00:00 2001 From: Joshua Burgin Date: Thu, 19 Apr 2018 16:23:11 -0500 Subject: [PATCH] Clean up formatting --- index.html | 130 ++++++++++++++++++++++----------------------- style.css | 88 +++++++++++++++--------------- task3.php | 94 ++++++++++++++++---------------- task4a-records.php | 84 ++++++++++++++--------------- task4a-songs.php | 70 ++++++++++++------------ task4b-search.php | 74 +++++++++++++------------- task4b.php | 110 +++++++++++++++++++------------------- 7 files changed, 325 insertions(+), 325 deletions(-) diff --git a/index.html b/index.html index 52cf60d..e4b1474 100644 --- a/index.html +++ b/index.html @@ -3,72 +3,72 @@ - Homework #8 - + Homework #8 + -
-

Task 3

-

View all tables and tuples in the database

- View Tables -
-
-

Task 4a

-

Query 1: Songs

-

This query shows a list of songs from a particular genre. Select a genre below.

-
- -
- -
- -

Query 2: Records & Artists

-

This query shows a list of records joined with their artists. Enter a year below to show all records that have come out since then.

-
- -
- -
-
-
-

Task 4b

-

Adding Employees

-

This form adds a new employee to the database. Enter employee details below:

-
-
- - -
-
- - -
-
- - -
-
- - -
- -
-

Query Employees

-

This query searches for employees by name. Enter a search term below to query.

-
- -
- -
-
+
+

Task 3

+

View all tables and tuples in the database

+ View Tables +
+
+

Task 4a

+

Query 1: Songs

+

This query shows a list of songs from a particular genre. Select a genre below.

+
+ +
+ +
+ +

Query 2: Records & Artists

+

This query shows a list of records joined with their artists. Enter a year below to show all records that have come out since then.

+
+ +
+ +
+
+
+

Task 4b

+

Adding Employees

+

This form adds a new employee to the database. Enter employee details below:

+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+

Query Employees

+

This query searches for employees by name. Enter a search term below to query.

+
+ +
+ +
+
- \ No newline at end of file + diff --git a/style.css b/style.css index f8b6867..5ac0b2e 100644 --- a/style.css +++ b/style.css @@ -1,84 +1,84 @@ body { - font-family: 'Helvetica', sans-serif; - margin: 0; - padding: 0; - text-align: center; + font-family: 'Helvetica', sans-serif; + margin: 0; + padding: 0; + text-align: center; } table { - border-collapse: collapse; - margin: 0 auto; + border-collapse: collapse; + margin: 0 auto; } th, td { - border: 1px solid #000; - padding: 5px 10px; - font-weight: normal; + border: 1px solid #000; + padding: 5px 10px; + font-weight: normal; } h3 { - margin: 0 0 10px; + margin: 0 0 10px; } .section { - text-align: center; - padding: 25px 0; - border-bottom: 1px solid #eee; - overflow: auto; + text-align: center; + padding: 25px 0; + border-bottom: 1px solid #eee; + overflow: auto; } select, input { - width: 150px; - margin-bottom: 10px; - height: 28px; - font-size: 15px; + width: 150px; + margin-bottom: 10px; + height: 28px; + font-size: 15px; } input { - text-indent: 8px; + text-indent: 8px; } button { - margin-bottom: 15px; + margin-bottom: 15px; } form { - width: 260px; - margin: 0 auto; + width: 260px; + margin: 0 auto; } .form-group { - width: 100%; - text-align: left; - float: left; - clear: both; + width: 100%; + text-align: left; + float: left; + clear: both; } .form-group label { - float: left; - clear: both; - margin-bottom: 5px; + float: left; + clear: both; + margin-bottom: 5px; } .form-group input { - float: left; - clear: both; - width: 100%; + float: left; + clear: both; + width: 100%; } .button { - background: #6AC2D7; - padding: 10px 15px; - color: #fff; - display: inline-block; - text-decoration: none; - border-radius: 5px; - font-size: 16px; - border: none; - clear: both; + background: #6AC2D7; + padding: 10px 15px; + color: #fff; + display: inline-block; + text-decoration: none; + border-radius: 5px; + font-size: 16px; + border: none; + clear: both; } a.return-link { - display: inline-block; - margin-top: 20px; -} \ No newline at end of file + display: inline-block; + margin-top: 20px; +} diff --git a/task3.php b/task3.php index 4ac975d..2bfb9e1 100644 --- a/task3.php +++ b/task3.php @@ -1,55 +1,55 @@ -query("SHOW TABLES"); - - function getRows($con, $tname) { - return $con->query("SELECT * FROM " . $tname); - } - - function getColumns($con, $tname) { - return $con->query("SHOW COLUMNS FROM ". $tname); - } +query("SHOW TABLES"); + + function getRows($con, $tname) { + return $con->query("SELECT * FROM " . $tname); + } + + function getColumns($con, $tname) { + return $con->query("SHOW COLUMNS FROM ". $tname); + } ?> - Task 3 - + Task 3 + - + - Return to Main Page - - -
-

- - - - - - - - - - - - - - - - - -
-
- + Return to Main Page + + +
+

+ + + + + + + + + + + + + + + + + +
+
+ - \ No newline at end of file + diff --git a/task4a-records.php b/task4a-records.php index c262a2c..ab6726b 100644 --- a/task4a-records.php +++ b/task4a-records.php @@ -1,52 +1,52 @@ -query("SELECT record.id, record.name, inventory, length, year, price, artist.id, artist.name, genre - FROM record, artist, artist_record WHERE artist_record.artist_id = artist.id AND artist_record.record_id = record.id - AND year >= '" . $_POST['year'] . "' ORDER BY year ASC"); + + $rows = $con->query("SELECT record.id, record.name, inventory, length, year, price, artist.id, artist.name, genre + FROM record, artist, artist_record WHERE artist_record.artist_id = artist.id AND artist_record.record_id = record.id + AND year >= '" . $_POST['year'] . "' ORDER BY year ASC"); ?> - Task 4a - Songs - + Task 4a - Songs + - + - Return to Main Page -
-

Showing All Records & Artists Since

- - - - - - - - - - - - - - - - - - - - - - - -
record.idrecord.nameinventorylengthyearpriceartist.idartist.namegenre
-
+ Return to Main Page +
+

Showing All Records & Artists Since

+ + + + + + + + + + + + + + + + + + + + + + + +
record.idrecord.nameinventorylengthyearpriceartist.idartist.namegenre
+
- \ No newline at end of file + diff --git a/task4a-songs.php b/task4a-songs.php index c71f412..265b266 100644 --- a/task4a-songs.php +++ b/task4a-songs.php @@ -1,45 +1,45 @@ -query("SHOW COLUMNS FROM song"); - $rows = $con->query("SELECT * FROM song WHERE genre = '" . $_POST['genre'] . "'"); + + $columns = $con->query("SHOW COLUMNS FROM song"); + $rows = $con->query("SELECT * FROM song WHERE genre = '" . $_POST['genre'] . "'"); ?> - Task 4a - Songs - + Task 4a - Songs + - + - Return to Main Page -
-

Showing All Songs

- - - - - - - - - - - - - - - - - -
-
+ Return to Main Page +
+

Showing All Songs

+ + + + + + + + + + + + + + + + + +
+
- \ No newline at end of file + diff --git a/task4b-search.php b/task4b-search.php index 13e61a5..66deed2 100644 --- a/task4b-search.php +++ b/task4b-search.php @@ -1,47 +1,47 @@ -query("SHOW COLUMNS FROM employee"); - $rows = $con->query("SELECT * FROM employee WHERE name LIKE '%$name%'"); + $name = $_POST["name"]; + + $columns = $con->query("SHOW COLUMNS FROM employee"); + $rows = $con->query("SELECT * FROM employee WHERE name LIKE '%$name%'"); ?> - Task 4a - Songs - + Task 4a - Songs + - + - Return to Main Page - -
-

Searchings Employees With Name ""

- - - - - - - - - - - - - - - - - -
-
+ Return to Main Page + +
+

Searchings Employees With Name ""

+ + + + + + + + + + + + + + + + + +
+
- \ No newline at end of file + diff --git a/task4b.php b/task4b.php index d90f72d..e20b6e2 100644 --- a/task4b.php +++ b/task4b.php @@ -1,65 +1,65 @@ -query("INSERT INTO employee (ssn, name, address, title) values ('$ssn', '$name', '$address', '$title')"); - } +query("SHOW COLUMNS FROM employee"); - $rows = $con->query("SELECT * FROM employee"); + $ssn = $_POST["ssn"]; + $name = $_POST["name"]; + $address = $_POST["address"]; + $title = $_POST["title"]; + $error = ''; + + if (!$ssn || !$name || !$title || !$address) { + $error = "Failed to create employee. Please provide all fields. "; + } + + if (strlen($ssn) != 11) { + $error = $error . "SSN must be 11 characters long."; + } + + if (!$error) { + $con->query("INSERT INTO employee (ssn, name, address, title) values ('$ssn', '$name', '$address', '$title')"); + } + + $columns = $con->query("SHOW COLUMNS FROM employee"); + $rows = $con->query("SELECT * FROM employee"); ?> - Task 4a - Songs - + Task 4a - Songs + - + - Return to Main Page - $error

"; } else { ?> - -
-

Employee created successfully. Return home to query the employee table.

-

Showing All Employees

- - - - - - - - - - - - - - - - - -
-
+ Return to Main Page + $error

"; } else { ?> + +
+

Employee created successfully. Return home to query the employee table.

+

Showing All Employees

+ + + + + + + + + + + + + + + + + +
+
- \ No newline at end of file +