COMPILER DESIGN
COMPILER DESIGN
php
session_start();
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if ($result->num_rows > 0) {
return $result->fetch_all(MYSQLI_ASSOC);
} else {
return array();
}
}
if ($result->num_rows > 0) {
return $result->fetch_all(MYSQLI_ASSOC);
} else {
return array();
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Autolink Motors</title>
<link rel="stylesheet" type="text/css" href="Cart.css">
<script src="Cart.js"></script>
<script>
// Function to dynamically filter products based on search input
function searchProducts(query) {
const productCards = document.querySelectorAll('.product-card');
query = query.toLowerCase();
productCards.forEach(card => {
const productName =
card.querySelector('h3').innerText.toLowerCase();
const shouldShow = productName.includes(query);
card.style.display = shouldShow ? 'block' : 'none';
});
}
</script>
</head>
<body>
<header>
<img class="div1" src="autoclear.png" alt="Autolink Motors Logo">
<nav>
<ul class="nav-list">
<li><a href="Index.html">Home</a></li>
<li><a href="Cart.html">Cart</a></li>
<li><a href="checkout.html">Checkout</a></li>
<li><a href="Aboutus.html">About Us</a></li>
<li><a href="contacts.html">Contacts</a></li>
</ul>
</nav>
</header>
<div class="group">
<svg class="icon" aria-hidden="true" viewBox="0 0 24 24">
<g>
<path d="M21.53 20.47l-3.66-3.66C19.195 15.24 20 13.214
20 11c0-4.97-4.03-9-9-9s-9 4.03-9 9 4.03 9 9 9c2.215 0 4.24-.804 5.808-
2.13l3.66
3.66c.147.146.34.22.53.22s.385-.073.53-.22c.295-.293.295-.767.002-
1.06zM3.5 11c0-4.135 3.365-7.5 7.5-7.5s7.5 3.365 7.5 7.5-3.365 7.5-7.5
7.5-7.5-3.365-7.5-7.5z"></path>
</g>
</svg>
<div class="container">
<div class="product-cards">
<?php
// Fetch products from the database
$products = getProducts();
<div class="cart">
<h2>Shopping Cart</h2>
<div id="cart-items">
<?php
// Display the cart
displayCart();
?>
</div>
<button onclick="checkout()">Checkout</button>
</div>
</div>
<script src="backend.js"></script>
</body>
</html>
<?php
$conn->close();
?>