rajko
New Coder
this is my idfk.php i have markt the buy button.
and this is my shoppingcart.php
Code:
<?php
session_start();
// Initialize the cart session if it hasn't been set
if (!isset($_SESSION['cart'])) {
$_SESSION['cart'] = array();
}
// Check if the product ID is passed via GET request
if (isset($_GET['productId'])) {
$productId = $_GET['productId'];
// Add the product ID to the cart session
$_SESSION['cart'][] = $productId;
}
?>
<!DOCTYPE html>
<?php require_once("./inc/verbinding.inc.php") ?>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link
rel="stylesheet"
href="[URL]https://unpkg.com/swiper@8/swiper-bundle.min.css[/URL]"
/>
<link rel="preconnect" href="[URL]https://fonts.googleapis.com[/URL]" />
<link rel="preconnect" href="[URL]https://fonts.gstatic.com[/URL]" crossorigin />
<link href="[URL]https://fonts.googleapis.com/css2?family=Prompt:wght@100;400;900&display=swap[/URL]" rel="stylesheet" />
<script src="[URL]https://cdn.jsdelivr.net/npm/[email protected]/dist/kute.min.js[/URL]"></script>
<!-- CSS only -->
<link href="[URL]https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css[/URL]" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
<!-- JavaScript Bundle with Popper -->
<script src="[URL]https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js[/URL]" integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2" crossorigin="anonymous"></script>
<script src="[URL]https://kit.fontawesome.com/21a135a865.js[/URL]" crossorigin="anonymous"></script>
<script src="[URL]https://unpkg.com/swiper@8/swiper-bundle.min.js[/URL]"></script>
<link rel="stylesheet" href="[URL]https://cdn.jsdelivr.net/npm/swiper@9/swiper-bundle.min.css[/URL]" />
<link
rel="stylesheet"
href="[URL]https://unpkg.com/swiper/swiper-bundle.min.css[/URL]"
/>
<title>mtg shop</title>
<link rel="stylesheet" href="stylee.css"/>
<link
rel="stylesheet"
href="[URL]https://unpkg.com/swiper/swiper-bundle.min.css[/URL]"
/>
</head>
<body>
<header>
<div class="col-md">
<div class="logo"><img src="./images/logo.png" alt=""></div>
</div>
<div class="col-xl">
<div class="header-links">
<ul>
<li><i class="fa-brands fa-discord"></i></li>
<li><i class="fa-brands fa-instagram"></i></li>
<li><i class="fa-brands fa-facebook-f"></i></li>
<li><i class="fa-brands fa-twitter"></i></li>
</ul>
</div>
<div class="shoppingcart">
<a href="./shoppingcart.php"><i class="fa-solid fa-basket-shopping"></i></a>
</div>
</div>
</header>
<section id="sectionone" class="screen">
<div class=container>
<div id="scene">
<div data-depth="0.1" class="bg">
<img src="[URL]https://i.pinimg.com/originals/26/4f/5c/264f5ca0a64ae857e0fde2694e16f2c3.png[/URL]" alt="">
</div>
<div data-depth="0.65" class="foto1">
<img src="[MEDIA=imgur]pPnIKhy[/MEDIA]
[I][SIZE=2][URL='https://i.imgur.com/pPnIKhy.png']View: https://i.imgur.com/pPnIKhy.png[/URL][/SIZE][/I]
" alt="">
</div>
<div data-depth="0.3" class="text">
<h1>MAGIC</h1>
</div>
<div data-depth="0.3" class="text">
<h2>THE GATHERING</h2>
</div>
<div data-depth="0.3" class="text">
<div class="arrow"><i class="fa-sharp fa-regular fa-arrow-down fa-bounce"></i></div>
</div>
</div>
</div>
</section>
<section class="sectioncurve"><div class="spacer layer3"></div></section>
<section class="sectiontwo">
<div class="container">
<div class="row">
<div class="text"><span>TOP SELLERS</span> </div>
</div>
</div>
<div class="swiper mySwiper">
<div class="swiper-wrapper">
<div class="swiper-slide "><img src="[URL]https://blog.cardkingdom.com/wp-content/uploads/2020/07/teferi-borderless.png[/URL]" alt=""></div>
<div class="swiper-slide "><img src="[URL]https://blog.cardkingdom.com/wp-content/uploads/2020/07/grim-tutor-borderless.png[/URL]" alt=""></div>
<div class="swiper-slide "><img src="[URL]https://blog.cardkingdom.com/wp-content/uploads/2020/07/ugin-m21.png[/URL]" alt=""></div>
<div class="swiper-slide "><img src="[URL]https://blog.cardkingdom.com/wp-content/uploads/2020/07/grim-tutor-1.png[/URL]" alt=""></div>
<div class="swiper-slide "><img src="[URL]https://blog.cardkingdom.com/wp-content/uploads/2020/07/terror-of-the-peaks-1.png[/URL]" alt=""></div>
<div class="swiper-slide "><img src="[URL]https://blog.cardkingdom.com/wp-content/uploads/2020/07/fiery-emancipation.png[/URL]" alt=""></div>
<div class="swiper-slide "><img src="[URL]https://blog.cardkingdom.com/wp-content/uploads/2020/07/elder-gargaroth-1.png[/URL]" alt=""></div>
<div class="swiper-slide "><img src="[URL]https://blog.cardkingdom.com/wp-content/uploads/2020/07/heroic-intervention-m21.png[/URL]" alt=""></div>
<div class="swiper-slide "><img src="[URL]https://blog.cardkingdom.com/wp-content/uploads/2020/07/azusa-m21.png[/URL]" alt=""></div>
</div>
</div>
</section>
<section class="sectioncurve"><div class="spacer layer1"></div></section>
<section class="sectionthree">
<div class="btnvert"><span>
<a role="link" data-filter="CD" class="btn btn-outline-light btn-lg data-filter">Commander decks</a>
<span></span>
<a role="link" data-filter="SD" class="btn btn-outline-light btn-lg data-filter">Standard decks</a>
<span></span>
<a role="link" data-filter="AC" class="btn btn-outline-light btn-lg data-filter">Accessories</a>
<span></span>
<a role="link" data-filter="all" class="btn btn-outline-light btn-lg data-filter">All</a>
</div>
<div class="products">
<div class="swiper mySwiper">
<div class="swiper-wrapper">
<?php
// Get the selected filter category
$filterCategory = isset($_GET['filter']) ? $_GET['filter'] : 'all';
// Construct the SQL query based on the selected filter category
$sql = ($filterCategory !== 'all') ? "SELECT * FROM product WHERE categorie = '$filterCategory'" : "SELECT * FROM product";
$cdm = $link->query($sql);
$resultaat = $cdm->fetchAll();
foreach ($resultaat as $data) {
?>
<swiper-slide class="filter-<?php echo $data['categorie']; ?>">
<div class="portfolio-item">
<img src="./images/<?php echo $data["foto"] ?>" width="60%" alt="">
<div class="subtext">
<p>€<?php echo $data["price"] ?></p>
</div>
<div class="glow-on-hover">
[COLOR=rgb(184, 49, 47)]<a role="link" href="./shoppingcart.php?action=add&productId=<?php echo $data['id']; ?>" class="buy-btn" data-product-id="<?php echo $data["id"] ?>">BUY</a>[/COLOR]
</div>
</div>
</swiper-slide>
<?php
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</section>
<section class="sectioncurve"><div class="spacer layer2"></div></section>
<section class="sectionsupport">
<div class="container">
<div class="text"><span>support</span></div>
<div class="tp-contact">
<div class="mui-col-md-2">
<label>Your Name</label>
<input type="text" name="contactp" id="contactp" maxlength="30" class="form-control what">
</div>
<div class="mui-col-md-2">
<label>Your Email </label>
<input type="text" name="emailid" id="emailid" maxlength="75" class="form-control what">
</div>
<div class="mui-col-md-2">
<label>Subject :</label>
<input type="text" name="subject" id="subject" maxlength="50" class="form-control what">
</div>
<div class="mui-col-md-6">
<label>Message </label>
<textarea id="Message" name="message" class="form-control what" style="width:96%;"></textarea>
</div>
<div class="mui-col-md-6">
<br>
<a href="09u98787" class="btn btn-lg btn-outline-aqua">send</a>
</div>
</div>
<div style="clear:both;"></div>
<br>
</form>
<div class="subtext"><p>open: mon-fri 10-17 <br><br>
Belgium, Hasselt, Vossenbergstraat 28</p></div>
</div>
</section>
<script src="[URL]https://cdn.jsdelivr.net/npm/swiper@9/swiper-bundle.min.js[/URL]"></script>
<script src="[URL]https://unpkg.com/swiper/swiper-bundle.min.js[/URL]"></script>
<script src="[URL]https://cdnjs.cloudflare.com/ajax/libs/gsap/3.5.1/gsap.min.js[/URL]"></script>
<script src="[URL]https://cdnjs.cloudflare.com/ajax/libs/parallax/3.1.0/parallax.min.js[/URL]"></script>
<script src="[URL]https://unpkg.com/swiper/swiper-bundle.min.js[/URL]"></script>
<script src="indexx.js" type="text/javascript"></script>
</body>
</html>
and this is my shoppingcart.php
Code:
<?php
session_start();
require_once("./inc/verbinding.inc.php");
// Check if the cart session exists and has product IDs
if (isset($_SESSION['cart']) && count($_SESSION['cart']) > 0) {
$productIds = implode(',', $_SESSION['cart']);
// Retrieve the products from the database
$sql = "SELECT * FROM product WHERE id IN ($productIds)";
$result = $link->query($sql);
if ($result) {
$products = $result->fetchAll();
} else {
// Handle database query error
die("Error: " . $link->error); // Display the error message and stop execution
}
} else {
$products = [];
}
// Close the database connection
$link = null;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="[URL]https://kit.fontawesome.com/21a135a865.js[/URL]" crossorigin="anonymous"></script>
<!-- CSS only -->
<link href="[URL]https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css[/URL]" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
<!-- JavaScript Bundle with Popper -->
<script src="[URL]https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js[/URL]" integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2" crossorigin="anonymous"></script>
<link rel="stylesheet" href="[URL]https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.2.0/css/datepicker.min.css[/URL]">
<link rel="stylesheet" href="shopping.css">
<title>Shopping Cart</title>
</head>
<body>
<header class="header">
<div class="container">
<div class="row">
<div class="col-sm"></div>
<div class="col-sm-6 text-center">
<h1>Shopping Cart</h1>
</div>
<div class="col-sm">
<div class="back">
<a href="./idfk.php" class="btn btn-lg btn-outline-aqua">Go Back</a>
</div>
</div>
</div>
</div>
</header>
<section class="section section-table mt-2">
<div class="container">
<table class="table table-data table-striped table-hover">
<thead>
<tr>
<th class="w-item" scope="col"><span>Item</span></th>
<th class="w-number" scope="col"><span>Number</span></th>
<th scope="col"><span>Name</span></th>
<th class="w-price" scope="col"><span>Price</span></th>
</tr>
</thead>
<tbody>
<?php foreach ($products as $product) { ?>
<tr>
<td class="w-item"><img src="./images/<?php echo $product["foto"] ?>" alt="<?php echo $product["name"] ?>"></td>
<td class="w-number">1</td>
<td><?php echo $product["name"] ?></td>
<td class="w-price">€<?php echo $product["price"] ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</section>
</body>
</html>
Last edited by a moderator: