diff options
Diffstat (limited to 'public/products.php')
-rw-r--r-- | public/products.php | 36 |
1 files changed, 16 insertions, 20 deletions
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' ?> |