Webbserverprogrammering 1

Show sourcecode

The following files exists in this folder. Click to view.

webbserverprogrammering/projekt/snake_oil_seller/php/

about_us.php
add_to_cart.php
admin.php
buy_cart.php
config.php
contact.php
create_products.php
create_tables.php
createtable.php
dbconnection.php
delete_post.php
delete_tables.php
deletepost.php
deletetable.php
entry.php
header.php
insert_posts.php
insertposts.php
leaderboard.php
log_in.php
log_out.php
main.php
my_account.php
question_maker.php
quiz_form.php
quiz_list.php
quiz_maker.php
result.php
select_posts.php
selectposts.php
shop.php
shop_item.php
shopping_cart.php
sign_in.php
title_card.php
update_posts.php
updateposts.php
user_verified.php
verify_page.php

shop_item.php

71 lines UTF-8 Windows (CRLF)
<?php
  
// Initierar sessionen
  
session_start();

  
/** @var PDO $dbconn*/
  
include ("dbconnection.php");
?>
<!DOCTYPE html>
<html lang="sv">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Item</title>
    <link href="../css/snake_oil.css" rel="stylesheet"> 
    <link href="../css/main.css" rel="stylesheet">
  </head>
  <body>
    <!-- Titel -->
    <?php include "title_card.php";?>

    <!-- Rubriker -->
    <?php include "header.php";?>

    <!-- Hämtar alla produkter och dess egenskaper -->
    <?php
      $item_id 
$_GET["item_id"];

      
$sql "SELECT * FROM product_items WHERE id = ?";
      
$fetch_items $dbconn->prepare($sql);
      
$fetch_items->execute(array($item_id));

      
$has_products false;

      echo 
"<div id='product_container_shop_item'>";

      while (
$products $fetch_items->fetch(PDO::FETCH_ASSOC)) {
          
$has_products true;

          
$product_id $products["id"];
          
$product_name $products["name"];
          
$product_price $products["price"];
          
$product_info $products["info"];
          
$product_img $products["img"];
          
$product_amount $products["amount"];
          
          echo 
"<div id='image_part'>
                <img id='product_image' src='../bilder/
$product_img'>
                </div>"
;

          echo 
"<div id='product_part'>
                <p style='font-size: 1.7em;'>
$product_name</p>
                <p>
$product_price kr</p>
                <p>
$product_info</p>
                <p>
$product_amount st</p>
                <button onclick='add_to_cart(
$product_id)'>Lägg produkt i kundvagn</button>
                </div>"
;

        }

        echo 
"</div>";

        if (!
$has_products) {
          echo 
"Klass saknar produkter";
        }
      
    
?>

    <script src="../js/use_cart.js"></script>

  </body>
</html>