1
1
mirror of https://github.com/neosubhamoy/neosubhamoy-portfolio.git synced 2025-12-19 23:59:35 +05:30

(refactor): following core/query_functions approach + (feature): implemented dynamic featured footer section

This commit is contained in:
2023-10-31 23:42:53 +05:30
parent a773bd7b4a
commit 000787ccd4
6 changed files with 80 additions and 43 deletions

View File

@@ -0,0 +1,31 @@
<?php
//function to create an array of all unique project years
function create_project_years_array($conn) {
$sql = "SELECT DISTINCT year FROM projects ORDER BY year DESC";
$result = $conn -> 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;
}
?>