mirror of
https://github.com/neosubhamoy/neosubhamoy-portfolio.git
synced 2025-12-19 19:23:02 +05:30
(refactor): implemented object,array based search result categories and multi table search on backend and frontend
This commit is contained in:
@@ -105,7 +105,14 @@ function perform_search(searchInput, searchDef, searchRes) {
|
|||||||
inject_no_results(response);
|
inject_no_results(response);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
inject_search_results(response);
|
const resultTags = [...new Set(response.map(item => item.tag))];
|
||||||
|
const result = {};
|
||||||
|
|
||||||
|
resultTags.forEach(tag => {
|
||||||
|
result[tag] = response.filter(item => item.tag === tag);
|
||||||
|
});
|
||||||
|
console.log(result);
|
||||||
|
inject_search_results(result.project);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function(error) {
|
error: function(error) {
|
||||||
|
|||||||
@@ -522,40 +522,6 @@ video {
|
|||||||
--tw-backdrop-sepia: ;
|
--tw-backdrop-sepia: ;
|
||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 640px) {
|
|
||||||
.container {
|
|
||||||
max-width: 640px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 768px) {
|
|
||||||
.container {
|
|
||||||
max-width: 768px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 1024px) {
|
|
||||||
.container {
|
|
||||||
max-width: 1024px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 1280px) {
|
|
||||||
.container {
|
|
||||||
max-width: 1280px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 1536px) {
|
|
||||||
.container {
|
|
||||||
max-width: 1536px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.fixed {
|
.fixed {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
}
|
}
|
||||||
@@ -920,6 +886,10 @@ video {
|
|||||||
height: 50px;
|
height: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.h-\[59vh\] {
|
||||||
|
height: 59vh;
|
||||||
|
}
|
||||||
|
|
||||||
.h-\[60vh\] {
|
.h-\[60vh\] {
|
||||||
height: 60vh;
|
height: 60vh;
|
||||||
}
|
}
|
||||||
@@ -936,14 +906,6 @@ video {
|
|||||||
height: 100vh;
|
height: 100vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
.h-\[57vh\] {
|
|
||||||
height: 57vh;
|
|
||||||
}
|
|
||||||
|
|
||||||
.h-\[59vh\] {
|
|
||||||
height: 59vh;
|
|
||||||
}
|
|
||||||
|
|
||||||
.w-0 {
|
.w-0 {
|
||||||
width: 0px;
|
width: 0px;
|
||||||
}
|
}
|
||||||
@@ -1488,6 +1450,10 @@ video {
|
|||||||
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.filter {
|
||||||
|
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
||||||
|
}
|
||||||
|
|
||||||
.transition {
|
.transition {
|
||||||
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-backdrop-filter;
|
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-backdrop-filter;
|
||||||
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
|
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
|
||||||
|
|||||||
@@ -7,8 +7,20 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
$keyword = $_POST['keyword'];
|
$keyword = $_POST['keyword'];
|
||||||
$results_projects = fetch_search_results_projects($conn, $keyword);
|
$results_projects = fetch_search_results_projects($conn, $keyword);
|
||||||
$results_socials = fetch_search_results_socials($conn, $keyword);
|
$results_socials = fetch_search_results_socials($conn, $keyword);
|
||||||
$results = array_merge($results_projects, $results_socials);
|
|
||||||
echo json_encode($results);
|
$results = [];
|
||||||
|
foreach ([$results_projects, $results_socials] as $array) {
|
||||||
|
if (!empty($array)) {
|
||||||
|
$results = array_merge($results, $array);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!empty($results)) {
|
||||||
|
echo json_encode($results);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo json_encode(array('results' => 'none', 'message' => ': ( No Results Found'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -51,6 +51,8 @@ function fetch_social_icon($conn, $platform_name) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---functions to fetch search results starts here---
|
||||||
|
//from projects table
|
||||||
function fetch_search_results_projects($conn, $keyword) {
|
function fetch_search_results_projects($conn, $keyword) {
|
||||||
$sql = "SELECT * FROM projects WHERE name LIKE '%$keyword%'";
|
$sql = "SELECT * FROM projects WHERE name LIKE '%$keyword%'";
|
||||||
$result = $conn -> query($sql);
|
$result = $conn -> query($sql);
|
||||||
@@ -62,10 +64,11 @@ function fetch_search_results_projects($conn, $keyword) {
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return array('results' => 'none', 'message' => ': ( No Results Found');
|
return array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//from socials table
|
||||||
function fetch_search_results_socials($conn, $keyword) {
|
function fetch_search_results_socials($conn, $keyword) {
|
||||||
$sql = "SELECT * FROM socials WHERE platform LIKE '%$keyword%'";
|
$sql = "SELECT * FROM socials WHERE platform LIKE '%$keyword%'";
|
||||||
$result = $conn -> query($sql);
|
$result = $conn -> query($sql);
|
||||||
@@ -77,7 +80,7 @@ function fetch_search_results_socials($conn, $keyword) {
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return array('results' => 'none', 'message' => ': ( No Results Found');
|
return array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
Reference in New Issue
Block a user