diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-05-08 13:20:14 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-05-08 13:20:14 +0200 |
commit | 847347fb5511f6c526e41e0e5963e6d4f3882e58 (patch) | |
tree | 7559f1dcb2b55871b17eed1d7081b10d97026108 /public | |
parent | 14997bb700d5bc30d69a48294ae26a7e566939c5 (diff) |
WIP show products in database
Diffstat (limited to 'public')
-rw-r--r-- | public/db.php | 1 | ||||
-rw-r--r-- | public/products.php | 36 |
2 files changed, 17 insertions, 20 deletions
diff --git a/public/db.php b/public/db.php new file mode 100644 index 0000000..6d158b7 --- /dev/null +++ b/public/db.php @@ -0,0 +1 @@ +<?php $cursor = new mysqli("localhost", "loek", "", "webs"); ?> diff --git a/public/products.php b/public/products.php index 077702a..e9c7cdf 100644 --- a/public/products.php +++ b/public/products.php @@ -1,4 +1,16 @@ <!DOCTYPE html> +<?php require "db.php"; ?> +<?php +function product_template($product) { + echo <<<"EOF" + <a href="/product.php?id=$product->id" class="product nolinkstyle"> + <img src="$product->img" alt=""> + <span class="price">$product->price</span> + <span class="name">$product->name</span> + </a> +EOF; +} +?> <html> <head> <?php include 'head.php' ?> @@ -10,26 +22,10 @@ <div class="main limwidth"> <h2>lijst met producten:</h2> <div class="products"> - <a href="/product.php?id=123" class="product nolinkstyle"> - <img src="img/placeholder.png" alt=""> - <span class="price">3,45</span> - <span class="name">courgette</span> - </a> - <a href="/product.php?id=123" class="product nolinkstyle"> - <img src="img/placeholder.png" alt=""> - <span class="price">3,45</span> - <span class="name">courgette</span> - </a> - <a href="/product.php?id=123" class="product nolinkstyle"> - <img src="img/placeholder.png" alt=""> - <span class="price">3,45</span> - <span class="name">courgette</span> - </a> - <a href="/product.php?id=123" class="product nolinkstyle"> - <img src="img/placeholder.png" alt=""> - <span class="price">3,45</span> - <span class="name">courgette</span> - </a> + <?php + $res = $cursor->query("select ID as id, image_path as img, price, name from webs.product"); + while ($product = $res->fetch_object()) product_template($product); + ?> </div> </div> <?php include 'footer.php' ?> |