Gitlab@Informatics

Skip to content
Snippets Groups Projects
Commit cc94bd56 authored by 65160270's avatar 65160270
Browse files

update-cart

parent a2a15708
No related branches found
No related tags found
No related merge requests found
...@@ -53,7 +53,7 @@ router.post("/add", upload.single("image"), async (req, res) => { ...@@ -53,7 +53,7 @@ router.post("/add", upload.single("image"), async (req, res) => {
const imagePath = "/uploads/" + req.file.filename; const imagePath = "/uploads/" + req.file.filename;
// แก้จาก 'image' เป็น 'image_url' // แก้จาก 'image' เป็น 'image_url'
await pool.execute("INSERT INTO products (name, price, stock, description, image_url) VALUES (?, ?, ?, ?)", await pool.execute("INSERT INTO products (name, price, stock, image_url) VALUES (?, ?, ?, ?)",
[name, price, stock, imagePath]); [name, price, stock, imagePath]);
res.redirect("/products"); res.redirect("/products");
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
</head> </head>
<body> <body>
<h2>รายการสินค้า</h2> <h2>รายการสินค้า</h2>
<a href="/products/add">Add</a> <a href="/products/add">เพิ่มสินค้า</a>
<table border="1"> <table border="1">
<tr> <tr>
<th>รูป</th> <th>รูป</th>
......
...@@ -2,37 +2,37 @@ ...@@ -2,37 +2,37 @@
<html lang="th"> <html lang="th">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Edit</title> <title>แก้ไขสินค้า</title>
</head> </head>
<body> <body>
<h2>Edit</h2> <h2>แก้ไขสินค้า</h2>
<form action="/products/edit/<%= product.id %>" method="POST" enctype="multipart/form-data"> <form action="/products/edit/<%= product.id %>" method="POST" enctype="multipart/form-data">
<label>product_id:</label> <label>รหัสสินค้า:</label>
<input type="text" name="product_id" value="<%= product.id %>" readonly> <input type="text" name="product_id" value="<%= product.id %>" readonly>
<br> <br>
<label>name:</label> <label>ชื่อสินค้า:</label>
<input type="text" name="name" value="<%= product.name %>" required> <input type="text" name="name" value="<%= product.name %>" required>
<br> <br>
<label>price:</label> <label>ราคา:</label>
<input type="number" name="price" value="<%= product.price %>" required> <input type="number" name="price" value="<%= product.price %>" required>
<br> <br>
<label>stock:</label> <label>จำนวนสินค้า:</label>
<input type="number" name="stock" value="<%= product.stock %>" required> <input type="number" name="stock" value="<%= product.stock %>" required>
<br> <br>
<label>description:</label> <label>คำบรรยายสินค้า:</label>
<textarea name="description" required><%= product.description %></textarea> <textarea name="description" required><%= product.description %></textarea>
<br> <br>
<label>image:</label> <label>เปลี่ยนรูปภาพ (อัพโหลดใหม่ถ้าต้องการ):</label>
<input type="file" name="image_url"> <input type="file" name="image">
<br> <br>
<button type="submit">submit</button> <button type="submit">บันทึกการแก้ไข</button>
</form> </form>
</body> </body>
</html> </html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment