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.php

69 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>Shop</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";?>
    
    <!-- Produkter -->
    <?php
      
echo "<div class='product_container' id='product_container_shop'>";

      
// Hämtar alla klasser
      
$sql_classes "SELECT * FROM product_classes WHERE id != 0";
      
$fetch_all $dbconn->prepare($sql_classes);
      
$fetch_all->execute(array());

      while (
$res_classes $fetch_all->fetch(PDO::FETCH_ASSOC)) {
        
$class_name $res_classes["name"];
        
$class_id $res_classes["id"];

        echo 
"<div class='class_column'>";
        echo 
"<p>$class_name</p>";
        echo 
"<div class='product_row'>";

        
$sql_items "SELECT * FROM product_items WHERE type_id = ?";
        
$fetch_items $dbconn->prepare($sql_items);
        
$fetch_items->execute(array($class_id));

        
$has_products false;

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

          
$product_id $res_products["id"];
          
$product_name $res_products["name"];
          
$product_price $res_products["price"];
          
$product_info $res_products["info"];

          echo 
"<a href='shop_item.php?item_id=$product_id' class='product_items'>$product_name</a>";

        }

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

        
// Stänger product_row samt class_column
        
echo "</div>";
        echo 
"</div>";
      }
    
?>
  </body>
</html>