diff options
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' ?> |