1
1
mirror of https://github.com/neosubhamoy/neosubhamoy-portfolio.git synced 2025-12-19 22:53:03 +05:30

(refactor): using fetch_all_reacords() function + (feature): implemented dynamic currently working on section

This commit is contained in:
2023-11-01 14:27:58 +05:30
parent e9eee6b1b0
commit 5edcf4c562
4 changed files with 32 additions and 15 deletions

View File

@@ -17,7 +17,7 @@
<h6 class="font-bold mb-8">Featured</h6>
<?php
$featured_projects_footer = fetch_featured_projects($conn);
$featured_projects_footer = fetch_all_records($conn, "featured_projects");
if($featured_projects_footer -> num_rows > 0) {
while($featured_footer_item = $featured_projects_footer -> fetch_assoc()) {

View File

@@ -809,10 +809,18 @@ video {
margin-top: 2.2rem;
}
.mb-24 {
margin-bottom: 6rem;
}
.flex {
display: flex;
}
.table {
display: table;
}
.hidden {
display: none;
}

View File

@@ -1,4 +1,11 @@
<?php
//function to fetch all records of the given table
function fetch_all_records($conn, $table_name) {
$sql = "SELECT * FROM $table_name";
$result = $conn -> query($sql);
return $result;
}
//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";
@@ -20,11 +27,4 @@ function fetch_projects_by_year($conn, $year) {
$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;
}
?>

View File

@@ -123,7 +123,7 @@ $years = create_project_years_array($conn);
<div class="w-full flex flex-col justify-center items-center mb-12">
<?php
$featured_projects = fetch_featured_projects($conn);
$featured_projects = fetch_all_records($conn,"featured_projects");
if($featured_projects -> num_rows > 0){
//show top 2 featured projects for sidebar
@@ -152,12 +152,21 @@ $years = create_project_years_array($conn);
?>
</div>
<h5 class="text-xl font-bold mb-5">Currently Working On</h5>
<div class="w-full flex flex-col justify-center flex-wrap mb-12">
<div class="w-fit my-[0.30rem] text-sm font-bold bg-bg_secondary px-3 py-1 rounded-full"><i class="fa-brands fa-react text-base mr-1 text-[#38BDF8]"></i> React Web Development</div>
<div class="w-fit my-[0.30rem] text-sm font-bold bg-bg_secondary px-3 py-1 rounded-full"><i class="fa-brands fa-android text-base mr-1 text-[#3FF989]"></i> Android OS & Apps</div>
<div class="w-fit my-[0.30rem] text-sm font-bold bg-bg_secondary px-3 py-1 rounded-full"><i class="fa-brands fa-python text-base mr-1 text-[#CD6CFB]"></i> Automation & Python</div>
<div class="w-fit my-[0.30rem] text-sm font-bold bg-bg_secondary px-3 py-1 rounded-full"><i class="fa-brands fa-js text-base mr-1 text-[#DCDF3F]"></i> Javascript Library</div>
<div class="w-fit my-[0.30rem] text-sm font-bold bg-bg_secondary px-3 py-1 rounded-full"><i class="fa-solid fa-robot text-base mr-1 text-[#EC4B4B]"></i> AI & ML</div>
<div class="w-full flex flex-col justify-center flex-wrap mb-24">
<?php
$working_on = fetch_all_records($conn, "working_on");
if($working_on -> num_rows > 0) {
//show all currently working on topics
while($working_on_topic = $working_on -> fetch_assoc()) {
echo"
<div class='w-fit my-[0.30rem] text-sm font-bold bg-bg_secondary px-3 py-1 rounded-full'><i class='".$working_on_topic['icon']."'></i> ".$working_on_topic['title']."</div>
";
}
}
?>
</div>
</div>
</div>