Skip to content

Commit

Permalink
1.0, site now works as it should, though the user experience still su…
Browse files Browse the repository at this point in the history
…cks.
  • Loading branch information
juele committed Oct 9, 2023
1 parent 2a7e2e6 commit ae2df9c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 79 deletions.
6 changes: 3 additions & 3 deletions code/codecart.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@
$result = $mysqli->query("SELECT `id`, `manufacturer_id`, `name`, `price`, `quantity`, `image`, `code` FROM `products` "
. "WHERE code='" . $get_code . "'");

//$code = '';
$id = '';
$name = '';
$price = '';
$image = '';
if ($result->num_rows > 0) {
$item = $result->fetch_object();
//$code = $item->code;
$id = $item->id;
$name = $item->name;
$price = $item->price;
$image = $item->image;
}
$itemArray = array($get_code => array('name' => $name, 'code' => $get_code, 'quantity' => $posted_quantity, 'price' => $price, 'image' => $image));
$itemArray = array($get_code => array('id' => $id, 'name' => $name, 'code' => $get_code, 'quantity' => $posted_quantity, 'price' => $price, 'image' => $image));
if (!empty($_SESSION["cart_item"])) {
if (!empty($get_code) && ($get_code == array_keys($_SESSION["cart_item"]))) {
foreach ($_SESSION["cart_item"] as $k => $v) {
Expand Down
20 changes: 11 additions & 9 deletions code/insert.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,24 @@
$new_customer_id = $mysqli->insert_id;
$sql = "INSERT INTO orders (customer_id, date) VALUES ('$new_customer_id', '$date')";
$mysqli->query($sql);
$mysqli->close();

//orderslines
$new_order_id = $mysli->insert_id;
$new_order_id = $mysqli->insert_id;

// creates an array with all the key names
$arr_ids = array_keys($_SESSION["cart_item"]);

foreach ($arr_ids as $id) {
foreach ($arr_ids as $code) {
// get's all the content of the id
$cart_content = $_SESSION["cart_item"][$id];
$cart_content = $_SESSION["cart_item"][$code];
// how to select feilds
$product_name = $content["name"];
$product_quantity = $content["quantity"];
$product_price = $content["price"];
$product_image = $content["image"];
// $product_name = $content["name"];
$product_quantity = $cart_content["quantity"];
$product_id = $cart_content['id'];
$sql = "INSERT INTO orderslines (product_id, order_id, amount) VALUES ('$product_id','$new_order_id','$product_quantity')";

$mysqli->query($sql);
}
$mysqli->close();
}
unset($_SESSION["cart_item"]);
header("location: ../index.php?page=store");
2 changes: 1 addition & 1 deletion includes/footer.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<footer><div class="footer">
<p>Emil215ps store website, 2023, Version 0.7d.</p>
<p>Emil215ps store website, 2023, Version 1.0a</p>
</div></footer>
</body>
</html>
67 changes: 1 addition & 66 deletions pages/start.php
Original file line number Diff line number Diff line change
@@ -1,68 +1,3 @@
<h1>Emils store</h1>
<p>Buy what you want.</p>
<p>we specialize in everything from computers to screens, we know how important lasagna is, too.</p>
<div class="slideshow-container">

<!-- Full-width images with number and caption text -->
<h2>Nogle af vores produkter:</h2>
<div class="mySlides fade">
<div class="numbertext">Produkt 1 / 3</div>
<img src="images/itanium.jpg" width="312" height="375">
<div class="text">Pitanium 9760</div>
</div>
<div class="mySlides fade">
<div class="numbertext">Produkt 2 / 3</div>
<img src="images/TFPC.jpg" width="312" height="375">
<div class="text">Family PC</div>
</div>
<div class="mySlides fade">
<div class="numbertext">Produkt 3 / 3</div>
<img src="images/2411.jpg" width="312" height="375">
<div class="text">MenQ 2411</div>
</div>
l
<!-- Next and previous buttons -->
<a class="prev" onclick="plusSlides(-1)">&#10094;</a>
<a class="next" onclick="plusSlides(1)">&#10095;</a>
</div>
<br>
<!-- The dots/circles -->
<div style="text-align:center">
<span class="dot" onclick="currentSlide(1)"></span>
<span class="dot" onclick="currentSlide(2)"></span>
<span class="dot" onclick="currentSlide(3)"></span>
</div>
<script>
let slideIndex = 1;
showSlides(slideIndex);
// Next/previous controls
function plusSlides(n) {
showSlides(slideIndex += n);
}
// Thumbnail image controls
function currentSlide(n) {
showSlides(slideIndex = n);
}
function showSlides(n) {
let i;
let slides = document.getElementsByClassName("mySlides");
let dots = document.getElementsByClassName("dot");
if (n > slides.length) {slideIndex = 1}
if (n < 1) {slideIndex = slides.length}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " active";
}
</script>
<p>we specialize in everything from computers to screens, we know how important lasagna is, too.</p>

0 comments on commit ae2df9c

Please sign in to comment.