-
Notifications
You must be signed in to change notification settings - Fork 0
S1 F1 #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: story1
Are you sure you want to change the base?
S1 F1 #5
Changes from all commits
c6c16fc
1a24e90
1207c30
f643073
67e3538
e763c3a
5a74b15
1ece9a1
ed67818
fee9710
66d0292
30ea1bd
e18e74d
637f1d7
c5d3547
dd3f2e7
bea8258
7aa4e6a
6734cf9
c6ac42b
70eb9d0
a4329bc
a3a41ba
e40bbfe
94116d5
57de818
f48a786
58825e6
1e4ceda
9e0b0de
35718f3
98a3452
eef3e2e
0dc09a9
04ad53d
d8ded0b
c19e629
8290329
38ea9ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,9 +3,17 @@ | |
|
|
||
| $db = connect(); | ||
|
|
||
| function getData($db) | ||
| /*** | ||
| * | ||
| * function connects to database | ||
| * | ||
| * @param PDO $db | ||
| * @return array | ||
| */ | ||
|
|
||
| function getData(PDO $db): array | ||
| { | ||
| $sql = $db->prepare('SELECT `id`, `common_name`, `latin_name`, `identification_image`, `canopy_level`, `life_span` FROM `Plants`;'); | ||
| $sql = $db->prepare('SELECT `id`, `common_name`, `latin_name`, `canopy_level`, `life_span` FROM `Plants`;'); | ||
|
|
||
| $sql->execute(); | ||
|
|
||
|
|
@@ -14,11 +22,117 @@ function getData($db) | |
| return $plants; | ||
| } | ||
|
|
||
| function processData($plants) | ||
| /*** | ||
| * | ||
| * function checks if the data retrieved from db is | ||
| * an indexed array and arranges it in to a list | ||
| * within a div that can be displayed | ||
| * | ||
| * @param array $plants | ||
| * @return string | ||
| */ | ||
|
|
||
| function processData(array $plants): string | ||
| { | ||
|
|
||
| if (array_keys($plants) !== range(0, count($plants) - 1)) { | ||
| return false; | ||
| } | ||
|
|
||
| $plantRow = ''; | ||
| foreach ($plants as $plant) { | ||
| $plantRow .= '<div class="plant">' . $plant['id'] . $plant['common_name'] . $plant['latin_name'] . $plant['identification_image'] . $plant['canopy_level'] . $plant['life_span']; | ||
| $plantRow .= | ||
| '<div class="row"><ul><li>' | ||
| . $plant['id'] . '</li><li>' | ||
| . $plant['common_name'] . '</li><li>' | ||
| . $plant['latin_name'] . '</li><li>' | ||
| . $plant['canopy_level'] . '</li><li>' | ||
| . $plant['life_span'] . '</li></ul></div>'; | ||
| } | ||
| return $plantRow; | ||
| } | ||
| } | ||
|
|
||
| /*** | ||
| * | ||
| * function retrieves an array of images from the db | ||
| * | ||
| * @param PDO $db | ||
| * @return array | ||
| */ | ||
|
|
||
| function getImage(PDO $db): array | ||
| { | ||
| $sql = $db->prepare('SELECT `identification_image` FROM `Plants` GROUP BY `id` ASC;'); | ||
|
|
||
| $sql->execute(); | ||
|
|
||
| $images = $sql->fetchAll(); | ||
|
|
||
| return $images; | ||
| } | ||
|
|
||
| /*** | ||
| * | ||
| * function checks if data retrieved from the db is | ||
| * an indexed array and wraps it in a div that can | ||
| * be displayed | ||
| * | ||
| * @param array $images | ||
| * @return string | ||
| */ | ||
|
|
||
| function displayImage(array $images): string { | ||
|
|
||
| if (array_keys($images) !== range(0, count($images) - 1)) | ||
| return false; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indent this. |
||
|
|
||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extra newline |
||
| $plantImage = ''; | ||
|
|
||
| foreach ($images as $image) { | ||
| $plantImage .= '<div><img class ="sourceImage" src="' . $image["identification_image"] . '"></div>'; | ||
| } | ||
| return $plantImage; | ||
| } | ||
|
|
||
| /*** | ||
| * | ||
| * function retrieves an array if id's from the database | ||
| * | ||
| * @param PDO $db | ||
| * @return array | ||
| */ | ||
|
|
||
| function getID(PDO $db) | ||
| { | ||
| $sql = $db->prepare('SELECT `id` FROM `Plants` GROUP BY `id` ASC;'); | ||
|
|
||
| $sql->execute(); | ||
|
|
||
| $ids = $sql->fetchAll(); | ||
|
|
||
| return $ids; | ||
| } | ||
|
|
||
| /*** | ||
| * | ||
| * function checks if data retrieved from db is | ||
| * an indexed array and wraps it so that it can be displayed | ||
| * | ||
| * @param array $ids | ||
| * @return string | ||
| */ | ||
|
|
||
| function displayID(array $ids): string { | ||
|
|
||
| if (array_keys($ids) !== range(0, count($ids) - 1)) | ||
| return false; | ||
|
|
||
| $plantId = ''; | ||
|
|
||
| foreach ($ids as $id) { | ||
| $plantId .= '<p>' . $id["id"] . '</p>'; | ||
| } | ||
| return $plantId; | ||
| } | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,17 +8,48 @@ | |
|
|
||
| $plants = getData($db); | ||
|
|
||
| $images = getImage($db); | ||
|
|
||
| $plantImageArray = displayImage($images); | ||
|
|
||
| $ids = getID($db); | ||
| $id = displayID($ids); | ||
|
|
||
| ?> | ||
|
|
||
| <!DOCTYPE html> | ||
| <html lang="eng"> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct html lang attribute is |
||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>Collectors App</title> | ||
| <link rel="stylesheet" type="text/css" href="index.css"> | ||
| <link rel="stylesheet" type="text/css" href="normalize.css"> | ||
| <link rel="stylesheet" type="text/css" href="styles/index.css"> | ||
| <link rel="stylesheet" type="text/css" href="styles/normalize.css"> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Normalize should come before your own CSS, because the browser will overwrite rules in downwards-order. You want your own rules to override normalize, not the other way around. |
||
| </head> | ||
| <body> | ||
| <div class="wrapper"> | ||
| <section> | ||
| <div class="table"> | ||
| <div class="head"> | ||
| <ul class="heading"> | ||
| <li>ID</li> | ||
| <li>Common Name</li> | ||
| <li>Latin Name</li> | ||
| <li>Canopy Level</li> | ||
| <li>Life Span</li> | ||
| </ul> | ||
| </div> | ||
| <?php echo processData($plants) ?> | ||
| </div> | ||
| </section> | ||
| <section> | ||
| <div class="images"> | ||
| <?php | ||
| echo $id; | ||
| echo $plantImageArray; | ||
| ?> | ||
|
|
||
| </div> | ||
| </section> | ||
| </div> | ||
| </body> | ||
| </html> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,162 @@ | ||
| * { | ||
| box-sizing: border-box; | ||
| list-style: none; | ||
| } | ||
|
|
||
| body { | ||
| background-image: url("../images/vine-wall.jpg"); | ||
| background-repeat: no-repeat; | ||
| background-size: cover; | ||
| } | ||
|
|
||
| .wrapper { | ||
| overflow: auto; | ||
| width: 100vw; | ||
| height: 100vh; | ||
| } | ||
|
|
||
| section { | ||
| float: left; | ||
| height: 100%; | ||
| width: 50%; | ||
| } | ||
|
|
||
| section div.table, section div.images { | ||
| width: 90%; | ||
| height: 80%; | ||
| margin: 10% 5%; | ||
| } | ||
|
|
||
| .table { | ||
| border:solid black; | ||
| height: 100%; | ||
| overflow-y: scroll; | ||
| } | ||
|
|
||
| .row { | ||
| width: 100%; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't seem to do anything. |
||
| } | ||
|
|
||
| .heading { | ||
| font-size: 1.2rem; | ||
| } | ||
|
|
||
| ul { | ||
| padding-top: 3%; | ||
| border-top: solid black; | ||
| width: 100%; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't seem to do anything. |
||
| text-align: center; | ||
| overflow: auto; | ||
| } | ||
|
|
||
| li { | ||
| margin-left: 9%; | ||
| height: 10%; | ||
| width: 18%; | ||
| float: left; | ||
| } | ||
|
|
||
| ul li:first-child { | ||
|
RachmannJoubert marked this conversation as resolved.
|
||
| margin-left: -3%; | ||
| width: 3%; | ||
| } | ||
|
|
||
| ul li:last-child { | ||
| width: 3%; | ||
| } | ||
|
|
||
| .images { | ||
| overflow: auto; | ||
| float: right; | ||
| border: solid black; | ||
| height: 100%; | ||
| width: 100%; | ||
| position: relative; | ||
| } | ||
|
|
||
| .images p { | ||
| position: absolute; | ||
| color: white; | ||
| font-size: 1.5rem; | ||
| } | ||
|
|
||
| .images p:first-child { | ||
| position: absolute; | ||
| } | ||
|
|
||
| .images p:first-child, .images p:nth-child(4), .images p:nth-child(7), .images p:nth-child(10), .images p:nth-child(13) { | ||
| left: 5%; | ||
| } | ||
|
|
||
| .images p:nth-child(2), .images p:nth-child(5), .images p:nth-child(8), .images p:nth-child(11), .images p:nth-child(14) { | ||
| left: 38.5%; | ||
| } | ||
|
|
||
| .images p:nth-child(3), .images p:nth-child(6), .images p:nth-child(9), .images p:nth-child(12), .images p:nth-child(15){ | ||
| left: 72%; | ||
| } | ||
|
|
||
| .images p:nth-child(4), .images p:nth-child(5), .images p:nth-child(6) { | ||
| top: 19.5%; | ||
| } | ||
|
|
||
| .images p:nth-child(7), .images p:nth-child(8), .images p:nth-child(9) { | ||
| top: 39%; | ||
| } | ||
|
|
||
| .images p:nth-child(10), .images p:nth-child(11), .images p:nth-child(12) { | ||
| top: 58.5%; | ||
| } | ||
|
|
||
| .images p:nth-child(13), .images p:nth-child(14), .images p:nth-child(15) { | ||
| top: 77.5%; | ||
| } | ||
|
|
||
| .images div { | ||
| padding: 0.5%; | ||
| height: 19.5%; | ||
| width: 33.3%; | ||
| overflow: hidden; | ||
| float: left; | ||
| } | ||
|
|
||
| .sourceImage { | ||
| object-fit: cover; | ||
| } | ||
|
|
||
| img { | ||
| object-fit: cover; | ||
| width: 100%; | ||
| height: 100%; | ||
| } | ||
|
|
||
| .wrapper { | ||
| overflow: auto; | ||
| } | ||
|
|
||
| @media only screen and (max-width: 1000px) { | ||
| section { | ||
| height: 100%; | ||
| width: 100%; | ||
| } | ||
| } | ||
|
|
||
| @media only screen and (max-width: 530px) { | ||
| .head { | ||
| width: 100%; | ||
| overflow-x: auto; | ||
| } | ||
|
|
||
|
RachmannJoubert marked this conversation as resolved.
|
||
| li { | ||
| font-size: 1rem; | ||
| margin-left: 8%; | ||
| } | ||
|
|
||
| ul li:first-child { | ||
| margin-left: -10%; | ||
| } | ||
|
|
||
| ul li:last-child { | ||
| margin-left: 13%; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra newline