Skip to content
Snippets Groups Projects
Commit e4f709f5 authored by AlphaThrone's avatar AlphaThrone
Browse files

feat: second atribute search

parent 24cbea53
Branches
Tags
No related merge requests found
...@@ -68,15 +68,14 @@ ...@@ -68,15 +68,14 @@
height: 35vh; height: 35vh;
background-color: #e9e9e9; background-color: #e9e9e9;
border-radius: 10px; border-radius: 10px;
border: ridge; border: none;
text-align: center; text-align: center;
cursor: pointer; cursor: pointer;
} }
.showItem img{ .showItem img{
border: ridge;
width: 90%; width: 90%;
height: auto; height: 50%;
margin-bottom: 5px; margin-bottom: 5px;
text-align: center; text-align: center;
} }
...@@ -105,4 +104,9 @@ ...@@ -105,4 +104,9 @@
width: 40%; width: 40%;
height: 35%; height: 35%;
} }
.showItem p{
text-align: left;
margin: 5px;
}
} }
\ No newline at end of file
...@@ -79,7 +79,7 @@ function changePage(page){ ...@@ -79,7 +79,7 @@ function changePage(page){
//XMLHttpRequest //XMLHttpRequest
const formdata = new FormData(); const formdata = new FormData();
var row = (page)*10; var row = (page-1)*10;
formdata.append('rows', row); formdata.append('rows', row);
formdata.append('search', document.getElementById("Searchinput").value); formdata.append('search', document.getElementById("Searchinput").value);
console.log(document.getElementById("Searchinput").value); console.log(document.getElementById("Searchinput").value);
......
...@@ -7,7 +7,14 @@ ...@@ -7,7 +7,14 @@
$conn = connect_database(); $conn = connect_database();
$query = "SELECT * FROM `item` WHERE `name` LIKE '%$search%' ORDER BY if (SUBSTRING(name, 1, length('$search'))='$search', 0, 1), name LIMIT $page , 10"; $query = "SELECT *
,(CASE WHEN name LIKE '%$search%' THEN 1 ELSE 0 END) +
(CASE WHEN `Seller_username` LIKE '%$search%' THEN 1 ELSE 0 END) AS priority
FROM item
WHERE name LIKE '%$search%'
OR Seller_username LIKE '%$search%'
ORDER BY priority DESC
LIMIT $page, 10";
$stmt = $conn->prepare($query); $stmt = $conn->prepare($query);
if (!$stmt){ if (!$stmt){
...@@ -33,7 +40,7 @@ ...@@ -33,7 +40,7 @@
$conn = connect_database(); $conn = connect_database();
$query = "SELECT COUNT(item_id) FROM `item` WHERE name LIKE '%$search%'"; $query = "SELECT COUNT(item_id) FROM `item` WHERE name LIKE '%$search%' OR Seller_username LIKE '%$search%'";
$stmt = $conn->prepare($query); $stmt = $conn->prepare($query);
if (!$stmt){ if (!$stmt){
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment