From 4fecce6ff09fb61408528214b6c20442569c7558 Mon Sep 17 00:00:00 2001 From: Atiwit Pattanapukdee <65160394@go.buu.ac.th> Date: Wed, 26 Mar 2025 17:36:31 +0700 Subject: [PATCH] Project Round 11 --- models/tourModel.js | 6 +++++- views/tour-details.ejs | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/models/tourModel.js b/models/tourModel.js index b3b335a..953de6e 100644 --- a/models/tourModel.js +++ b/models/tourModel.js @@ -78,7 +78,11 @@ class Tour { // ดึงทัวร์ตาม ID static async getTourById(tourId) { - const query = 'SELECT id, name, description, price, duration, userId FROM tours WHERE id = ?'; + const query = ` + SELECT t.id, t.name, t.description, t.price, t.duration, t.userId, c.name AS company_name + FROM tours t + JOIN company c ON t.company_id = c.id + WHERE t.id = ?`; try { const [results] = await pool.execute(query, [tourId]); diff --git a/views/tour-details.ejs b/views/tour-details.ejs index b9be590..b115db4 100644 --- a/views/tour-details.ejs +++ b/views/tour-details.ejs @@ -13,9 +13,11 @@ <section> <h2>รายละเอียดทัวร์</h2> - <p>รายละเอียด: <%= tour.description %></p> - <p>Price: <%= tour.price %> THB</p> - <p>ระยะเวลา: <%= tour.duration %> วัน</p> + <p><strong>ชื่อทัวร์:</strong> <%= tour.name %></p> + <p><strong>คำอธิบาย:</strong> <%= tour.description %></p> + <p><strong>ราคา:</strong> <%= tour.price %></p> + <p><strong>ระยะเวลา:</strong> <%= tour.duration %></p> + <p><strong>บริษัท:</strong> <%= tour.company_name %></p> <a href="/" class="btn-edit">ย้อนกลับ</a> </section> -- GitLab