diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-05-08 17:14:06 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-05-08 17:14:06 +0200 |
commit | f3b582307cc3caf5ee0c7514d461e47fb5893bc7 (patch) | |
tree | 8865da67af7ae04d870481af155781c9a82ff0a7 | |
parent | cda96d31939c7ea727c114b162f43bb4d18314a2 (diff) |
uppercase is dumb
-rw-r--r-- | db/data.sql | 4 | ||||
-rw-r--r-- | db/init.sql | 30 | ||||
-rw-r--r-- | public/index.php | 2 | ||||
-rw-r--r-- | public/product.php | 2 | ||||
-rw-r--r-- | public/products.php | 4 |
5 files changed, 23 insertions, 19 deletions
diff --git a/db/data.sql b/db/data.sql index 55f59df..fb85463 100644 --- a/db/data.sql +++ b/db/data.sql @@ -15,6 +15,10 @@ insert into webs.product (`name`, `price`, `category`, `image`) values ("Kip", 9.95, 3, false), ("Kikker", 19.95, 3, false); +update webs.product set description = "<ul><li>lekker sappig</li><li>zonder BTW</li></ul>" where id = 1; +update webs.product set description = "<ul><li>snel bruin</li><li>zonder BTW</li></ul>" where id = 2; +update webs.product set description = "<ul><li>kurkdroog</li><li>zonder BTW</li></ul>" where id = 3; + insert into webs.customer (`name`) values ("loek"), ("bert"), diff --git a/db/init.sql b/db/init.sql index a9fc25b..4be1768 100644 --- a/db/init.sql +++ b/db/init.sql @@ -1,61 +1,61 @@ create schema if not exists webs; create table if not exists webs.category ( - `ID` int not null auto_increment, + `id` int not null auto_increment, `name` varchar(45) not null, `parent` int null default null, - primary key (`ID`), + primary key (`id`), constraint `category_parent_fk` foreign key (`parent`) - references webs.category (`ID`) + references webs.category (`id`) on update cascade ); create table if not exists webs.product ( - `ID` int not null auto_increment, + `id` int not null auto_increment, `name` varchar(255) not null, `price` decimal(5, 2) not null, `image` boolean not null default false, `description` mediumtext null default null, `category` int not null, - primary key (`ID`), + primary key (`id`), constraint `product_category_fk` foreign key (`category`) - references webs.category (`ID`) + references webs.category (`id`) on update cascade ); create table if not exists webs.customer ( - `ID` int not null auto_increment, + `id` int not null auto_increment, `name` varchar(45) not null, - primary key (`ID`) + primary key (`id`) ); create table if not exists webs.cart ( - `ID` int not null auto_increment, + `id` int not null auto_increment, `product` int not null, `customer` int not null, `count` int not null default 1, - primary key (`ID`), + primary key (`id`), constraint `cart_product_fk` foreign key (`product`) - references webs.product (`ID`) + references webs.product (`id`) on update cascade, constraint `cart_customer_fk` foreign key (`customer`) - references webs.customer (`ID`) + references webs.customer (`id`) on update cascade ); create table if not exists webs.promotion ( - `ID` int not null auto_increment, + `id` int not null auto_increment, `product` int not null, `count_buff` int not null default 1, `price_buff` decimal(4, 3) not null default 1.0, - primary key (`ID`), + primary key (`id`), constraint `promotion_product_fk` foreign key (`product`) - references webs.product (`ID`) + references webs.product (`id`) on update cascade ); diff --git a/public/index.php b/public/index.php index 653962c..84dc753 100644 --- a/public/index.php +++ b/public/index.php @@ -13,7 +13,7 @@ <h1>hier zijn de aanbiedingen</h1> <ul> <?php - $res = $cursor->query("select product.ID as id, product.name as name from promotion join product on product.ID = promotion.product"); + $res = $cursor->query("select product.id, product.name as name from promotion join product on product.id = promotion.product"); while ($product = $res->fetch_object()) { echo "<li><a href=\"/product.php?id=$product->id\">$product->name</a></li>"; } diff --git a/public/product.php b/public/product.php index 3e6a89f..7db5b5e 100644 --- a/public/product.php +++ b/public/product.php @@ -6,7 +6,7 @@ function refuse() { die(); } -$statement = $cursor->prepare("select ID as id, image, price, name, description from webs.product where ID = ?"); +$statement = $cursor->prepare("select id, image, price, name, description from webs.product where id = ?"); $statement->bind_param("i", $_GET['id']); if (!$statement->execute()) refuse(); $res = $statement->get_result(); diff --git a/public/products.php b/public/products.php index bffaeb0..fd3e2a1 100644 --- a/public/products.php +++ b/public/products.php @@ -2,7 +2,7 @@ <?php require "db.php"; ?> <?php function product_template($product) { - $image_path = $product->img ? "/img/product/$product->id-thumb.jpg" : "/img/placeholder.png"; + $image_path = $product->image ? "/img/product/$product->id-thumb.jpg" : "/img/placeholder.png"; echo <<<"EOF" <a href="/product.php?id=$product->id" class="product nolinkstyle"> <img src="$image_path" alt=""> @@ -24,7 +24,7 @@ EOF; <h2>lijst met producten:</h2> <div class="products"> <?php - $res = $cursor->query("select ID as id, image as img, price, name from webs.product"); + $res = $cursor->query("select id, image, price, name from webs.product"); while ($product = $res->fetch_object()) product_template($product); ?> </div> |