diff --git a/htdocs/assets/_footer.php b/htdocs/assets/_footer.php index 2261832..ce20b63 100644 --- a/htdocs/assets/_footer.php +++ b/htdocs/assets/_footer.php @@ -15,13 +15,19 @@
Featured
- Featured Project 1 - Featured 2 - Featured Content 3 - Featured Project - Featured Project - Featured Content 6 - Featured 7 + num_rows > 0) { + while($featured_footer_item = $featured_projects_footer -> fetch_assoc()) { + echo " + ".$featured_footer_item['name']." + "; + } + } + + ?>
Follow Me On
diff --git a/htdocs/blog.php b/htdocs/blog.php index 2e38aad..1917a25 100644 --- a/htdocs/blog.php +++ b/htdocs/blog.php @@ -1,3 +1,8 @@ + + diff --git a/htdocs/contact.php b/htdocs/contact.php index f8f334c..19af818 100644 --- a/htdocs/contact.php +++ b/htdocs/contact.php @@ -1,3 +1,8 @@ + + diff --git a/htdocs/core/query_functions.php b/htdocs/core/query_functions.php new file mode 100644 index 0000000..aaf7419 --- /dev/null +++ b/htdocs/core/query_functions.php @@ -0,0 +1,31 @@ + query($sql); + + if ($result) { + $years = array(); + while ($row = $result -> fetch_assoc()) { + $years[] = $row['year']; + } + + return $years; + } +} + +//function to fetch all projects of the given year +function fetch_projects_by_year($conn, $year) { + $sql = "SELECT * FROM projects WHERE year = $year ORDER BY id DESC"; + $result = $conn -> query($sql); + return $result; +} + +//function to fetch top 2 featured projects for sidebar +function fetch_featured_projects($conn) { + $sql = "SELECT * FROM featured_projects"; + $result = $conn -> query($sql); + return $result; +} +?> \ No newline at end of file diff --git a/htdocs/index.php b/htdocs/index.php index f9ad3a7..25c11e0 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -1,3 +1,8 @@ + + diff --git a/htdocs/projects.php b/htdocs/projects.php index 22eae25..629e9e9 100644 --- a/htdocs/projects.php +++ b/htdocs/projects.php @@ -1,32 +1,8 @@ query($sql); - -if ($result) { - // create a array of all unique years - $years = array(); - while ($row = $result -> fetch_assoc()) { - $years[] = $row['year']; - } - - $result -> free(); -} - -//function to fetch all projects of the given year -function fetch_projects_by_year($conn, $year) { - $sql = "SELECT * FROM projects WHERE year = $year ORDER BY id DESC"; - $result = $conn -> query($sql); - return $result; -} - -//function to fetch top 2 featured projects for sidebar -function fetch_featured_projects_sidebar($conn) { - $sql = "SELECT * FROM featured_projects LIMIT 2"; - $result = $conn -> query($sql); - return $result; -} +$years = create_project_years_array($conn); ?> @@ -147,21 +123,30 @@ function fetch_featured_projects_sidebar($conn) {
num_rows > 0){ + //show top 2 featured projects for sidebar + $counter = 0; while($featured_item = $featured_projects -> fetch_assoc()) { - echo " -
- - "; + "; + } + $counter++; + if ($counter >= 2) { + break; + } } + } ?>