Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c6c16fc
added prototype search function
RachmannJoubert Aug 6, 2019
1a24e90
removed search function and html form
RachmannJoubert Aug 7, 2019
1207c30
add functions to get image and display image
RachmannJoubert Aug 7, 2019
f643073
background image
RachmannJoubert Aug 7, 2019
67e3538
added functions to create the table and started styling the table
RachmannJoubert Aug 7, 2019
e763c3a
altered process data function so that it creates the desired table fo…
RachmannJoubert Aug 7, 2019
5a74b15
called the processData function to create the table
RachmannJoubert Aug 7, 2019
1ece9a1
styled the table so that it scrolls to acomodate overflow
RachmannJoubert Aug 7, 2019
ed67818
altered table styling so that columns are appropriately spaced
RachmannJoubert Aug 7, 2019
fee9710
removed getTableBody and getHeadings functions
RachmannJoubert Aug 7, 2019
66d0292
removed redundant function calls and created a div to display images
RachmannJoubert Aug 7, 2019
30ea1bd
adjusted styling for tables so that they align next to eachother and …
RachmannJoubert Aug 7, 2019
e18e74d
added functions to get and display ID's
RachmannJoubert Aug 7, 2019
637f1d7
created test folder
RachmannJoubert Aug 7, 2019
c5d3547
alligned images within div, ordered id's and altered position of sect…
RachmannJoubert Aug 7, 2019
dd3f2e7
gave image id's a top and left value to align over coresponding image
RachmannJoubert Aug 8, 2019
bea8258
un commented displayID array
RachmannJoubert Aug 8, 2019
7aa4e6a
called displayID function and echod id's
RachmannJoubert Aug 8, 2019
6734cf9
moved css files to a seperate styles folder
RachmannJoubert Aug 8, 2019
c6ac42b
moved css files to a style folder
RachmannJoubert Aug 8, 2019
70eb9d0
removed commented code and altered font size of headings
RachmannJoubert Aug 8, 2019
a4329bc
altered structure of code and removed extra line spacing
RachmannJoubert Aug 8, 2019
a3a41ba
removed extra lines and indented where it was missing
RachmannJoubert Aug 8, 2019
e40bbfe
vreated test for processData and displayid functions
RachmannJoubert Aug 8, 2019
94116d5
began work on responsive testing
RachmannJoubert Aug 8, 2019
57de818
completed success tests for relevent functions
RachmannJoubert Aug 8, 2019
f48a786
changed structure of processData function so that operators start on …
RachmannJoubert Aug 8, 2019
58825e6
completed malformed tests for relevent functions
RachmannJoubert Aug 8, 2019
1e4ceda
structured arrays to make them easier to read
RachmannJoubert Aug 8, 2019
9e0b0de
added if statements into functions to check whether they are getting …
RachmannJoubert Aug 8, 2019
35718f3
removed unnecessary media queries and line spacings
RachmannJoubert Aug 8, 2019
98a3452
fixed spelling mistake
RachmannJoubert Aug 8, 2019
eef3e2e
completed doc blocks for functions
RachmannJoubert Aug 8, 2019
0dc09a9
removed redundant doc blocks
RachmannJoubert Aug 8, 2019
04ad53d
added in breakpoints so that tables shrink more naturaly
RachmannJoubert Aug 8, 2019
d8ded0b
removed extra line spaces
RachmannJoubert Aug 8, 2019
c19e629
changed getImage query so that it returns them in order
RachmannJoubert Aug 8, 2019
8290329
changed format of code
RachmannJoubert Aug 8, 2019
38ea9ee
added media queries for headings
RachmannJoubert Aug 8, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 119 additions & 5 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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
{

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra newline

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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent this.
Also, you don't need the curlyboys for a one-liner if statement, but they do help readability.



Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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;
}

Binary file added images/vine-wall.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 0 additions & 4 deletions index.css

This file was deleted.

35 changes: 33 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,48 @@

$plants = getData($db);

$images = getImage($db);

$plantImageArray = displayImage($images);

$ids = getID($db);
$id = displayID($ids);

?>

<!DOCTYPE html>
<html lang="eng">

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct html lang attribute is en

<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">

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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>
162 changes: 162 additions & 0 deletions styles/index.css
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%;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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%;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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 {
Comment thread
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;
}

Comment thread
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%;
}
}
File renamed without changes.
Loading