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

30 lines
810 B
PHP

<?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 all featured projects
function fetch_featured_projects($conn) {
$sql = "SELECT * FROM featured_projects";
$result = $conn -> query($sql);
return $result;
}
?>