Skip to content
Snippets Groups Projects
Commit 002c33bd authored by Ignacio Hernández de la Fuente's avatar Ignacio Hernández de la Fuente
Browse files
parents 06fe8fba c69d5d6c
No related branches found
No related tags found
No related merge requests found
<?php
include("../connect_database.php");
if (isset($_GET['query'])) {
$search_query = $_GET['query'];
// Use the search query to fetch matching articles from the database
$sql = "SELECT * FROM articles WHERE itemName LIKE '%$search_query%'";
$result = $conn->query($sql);
$articles = array();
while ($row = $result->fetch_assoc()) {
$articles[] = $row;
}
// Return the search results as JSON
echo json_encode($articles);
} else {
echo json_encode(array()); // Return an empty array if no query is provided
}
$conn->close();
?>
...@@ -43,6 +43,7 @@ switch ($j) { ...@@ -43,6 +43,7 @@ switch ($j) {
} }
include("../html/data_treatment/connect_database.php"); include("../html/data_treatment/connect_database.php");
echo "Hello Mr./Ms. ".explode('@',$_SESSION["username"])[0].", you were last online on ".$Fday." - ".$day.".".$month.".".$year.".";
?> ?>
<html lang="en"> <html lang="en">
<head> <head>
...@@ -83,7 +84,7 @@ include("../html/data_treatment/connect_database.php"); ...@@ -83,7 +84,7 @@ include("../html/data_treatment/connect_database.php");
</li> </li>
<li> <li>
<form action="/search" method="GET"> <form method="GET">
<input type="text" name="query" id=search placeholder="Search..."> <input type="text" name="query" id=search placeholder="Search...">
</form> </form>
</li> </li>
...@@ -320,14 +321,20 @@ include("../html/data_treatment/connect_database.php"); ...@@ -320,14 +321,20 @@ include("../html/data_treatment/connect_database.php");
<div class="container"> <div class="container">
<div class="row justify-content-center"> <div class="row justify-content-center">
<div class="col-lg-8"> <div class="col-lg-8">
<div class="modal-body"> <div class="modal-body" <?php echo 'id="modal'.$articles[$i]["itemName"].'"';?>>
<!-- Project details--> <!-- Project details-->
<h2 class="text-uppercase"><?php echo $articles[$i]["itemName"]?></h2> <h2 class="text-uppercase"><?php echo $articles[$i]["itemName"]?></h2>
<!-- <p class="item-intro text-muted">Lorem ipsum dolor sit amet consectetur.</p> --> <!-- <p class="item-intro text-muted">Lorem ipsum dolor sit amet consectetur.</p> -->
<img class="img-fluid d-block mx-auto" src=<?php echo "'../image/laptops/".$articles[$i]["imagename"]."'"; ?> alt="..." /> <img class="img-fluid d-block mx-auto" src=<?php echo "'../image/laptops/".$articles[$i]["imagename"]."'"; ?> alt="..." />
<p><?php echo $articles[$i]["description"]; ?></p> <p><?php echo $articles[$i]["description"]; ?></p>
<p><?php echo "Price: ".$articles[$i]["price"]." €";?></p> <p><?php echo "Price: ".$articles[$i]["price"]." € <br>Quantity available: ".$articles[$i]["quantity"];?></p>
<button class="btn btn-primary btn-xl text-uppercase" data-bs-dismiss="modal" type="button"> <div class="quantity">
<button class="remove-button" onclick="removeProduct(this)">X</button>
<button onclick="decrementQuantity(this)">-</button>
<input type="text" value="1" <?php echo 'id="quantity"'.$i; ?>>
<button onclick="incrementQuantity(this)">+</button>
</div>
<button class="btn btn-primary btn-xl text-uppercase" type="button" <?php echo 'id = "buttonShoppingCart'.$i.'"';?>>
Add to shopping cart Add to shopping cart
</button> </button>
<div class="quantity"> <div class="quantity">
...@@ -409,6 +416,24 @@ include("../html/data_treatment/connect_database.php"); ...@@ -409,6 +416,24 @@ include("../html/data_treatment/connect_database.php");
<script src="https://cdn.startbootstrap.com/sb-forms-latest.js"></script> <script src="https://cdn.startbootstrap.com/sb-forms-latest.js"></script>
<script src="js/slideBox.js"></script> <script src="js/slideBox.js"></script>
<script> <script>
function incrementQuantity(button) {
var input = button.parentNode.querySelector('input');
var value = parseInt(input.value, 10);
input.value = value + 1;
}
function decrementQuantity(button) {
var input = button.parentNode.querySelector('input');
var value = parseInt(input.value, 10);
if (value > 0) {
input.value = value - 1;
}
}
function removeProduct(button) {
var product = button.parentNode.parentNode;
product.parentNode.removeChild(product);
}
function updateOnlineUsers() { function updateOnlineUsers() {
$.ajax({ $.ajax({
url: '../html/data_treatment/AJAX/online_Users.php', url: '../html/data_treatment/AJAX/online_Users.php',
...@@ -423,6 +448,8 @@ include("../html/data_treatment/connect_database.php"); ...@@ -423,6 +448,8 @@ include("../html/data_treatment/connect_database.php");
// Initial update // Initial update
updateOnlineUsers(); updateOnlineUsers();
</script> </script>
</body> </body>
</html> </html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment