Gitlab@Informatics
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cloudupdate_prj
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
65160270
cloudupdate_prj
Commits
cc94bd56
Commit
cc94bd56
authored
2 weeks ago
by
65160270
Browse files
Options
Downloads
Patches
Plain Diff
update-cart
parent
a2a15708
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
shop-routes/product.js
+1
-1
1 addition, 1 deletion
shop-routes/product.js
views/product.ejs
+1
-1
1 addition, 1 deletion
views/product.ejs
views/product_edit.ejs
+10
-10
10 additions, 10 deletions
views/product_edit.ejs
with
12 additions
and
12 deletions
shop-routes/product.js
+
1
−
1
View file @
cc94bd56
...
@@ -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
"
);
...
...
This diff is collapsed.
Click to expand it.
views/product.ejs
+
1
−
1
View file @
cc94bd56
...
@@ -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>
...
...
This diff is collapsed.
Click to expand it.
views/product_edit.ejs
+
10
−
10
View file @
cc94bd56
...
@@ -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>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment