From e17109d13e071072bfd56432ade7059ab289e59a Mon Sep 17 00:00:00 2001 From: Ben PC Date: Thu, 31 Mar 2022 10:50:08 +0200 Subject: [PATCH] multiple images --- index.js | 30 ++++++++++++++++++------------ views/product.ejs | 26 ++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/index.js b/index.js index 7700335..3e506c9 100644 --- a/index.js +++ b/index.js @@ -185,18 +185,24 @@ app.get("/product/:productId", authNoRedirectHandler, (req, res) => { if(err) throw err; let categories = JSON.parse(JSON.stringify(result)); - let dict = { - title: product.productName, - product: product, - shippingDays: 3, - stockAmount: 50, - productDescription: "ez", - loggedIn: true, - reviews: reviews, - categories: categories, - user: req.user, - } - res.render('product', dict) + mysql_handler.con.query(`SELECT url FROM product_images WHERE product_id = ${product.id};`,function(err,result){ + if(err) throw err; + let images = JSON.parse(JSON.stringify(result)); + + let dict = { + title: product.productName, + product: product, + shippingDays: 3, + stockAmount: 50, + productDescription: "ez", + loggedIn: true, + reviews: reviews, + categories: categories, + images: images, + user: req.user, + } + res.render('product', dict) + }); }); }); diff --git a/views/product.ejs b/views/product.ejs index 2198370..93bb17c 100644 --- a/views/product.ejs +++ b/views/product.ejs @@ -13,7 +13,9 @@
- + + +

<%= product.productName %>


@@ -98,4 +100,24 @@
<%- include('partials/footer'); %> - \ No newline at end of file + + + \ No newline at end of file