Gitlab@Informatics

Skip to content
Snippets Groups Projects
Commit 0ec926f4 authored by 65160394's avatar 65160394
Browse files

Project Round 10

parent 6fce0c93
No related branches found
No related tags found
No related merge requests found
...@@ -53,19 +53,19 @@ class Tour { ...@@ -53,19 +53,19 @@ class Tour {
// อัปเดตทัวร์ // อัปเดตทัวร์
static async updateTour(tourId, tourData) { static async updateTour(tourId, tourData) {
const { name, description, price, duration } = tourData; const { name, description, price, duration, companyid } = tourData;
// ตรวจสอบข้อมูลให้ครบถ้วน // ตรวจสอบข้อมูลให้ครบถ้วน
if (!name || !description || !price || !duration) { if (!name || !description || !price || !duration|| !companyid) {
throw new Error('ข้อมูลไม่ครบถ้วน'); throw new Error('ข้อมูลไม่ครบถ้วน');
} }
// สร้างคำสั่ง SQL สำหรับการอัปเดตข้อมูล // สร้างคำสั่ง SQL สำหรับการอัปเดตข้อมูล
const query = 'UPDATE tours SET name = ?, description = ?, price = ?, duration = ? WHERE id = ?'; const query = 'UPDATE tours SET name = ?, description = ?, price = ?, duration = ? , companyid = ? WHERE id = ?';
try { try {
// ใช้ tourId ที่รับมาในการอัปเดต // ใช้ tourId ที่รับมาในการอัปเดต
const [results] = await pool.execute(query, [name, description, price, duration, tourId]); const [results] = await pool.execute(query, [name, description, price, duration, companyid, tourId]);
console.log('✅ Update results:', results); console.log('✅ Update results:', results);
return results; return results;
} catch (error) { } catch (error) {
......
...@@ -26,6 +26,15 @@ ...@@ -26,6 +26,15 @@
<label for="tourDuration">ระยะเวลา (วัน):</label> <label for="tourDuration">ระยะเวลา (วัน):</label>
<input type="number" id="tourDuration" name="duration" value="<%= tour.duration %>" required> <input type="number" id="tourDuration" name="duration" value="<%= tour.duration %>" required>
</div> </div>
<div>
<label for="tourCompany">บริษัท:</label>
<select id="tourCompany" name="companyid" required>
<option value="" disabled selected>เลือกบริษัท</option>
<option value="1">Amazing Travel</option>
<option value="2">Wonderful Tours</option>
<option value="3">Explore Asia</option>
</select>
</div>
<button type="submit">Update Tour</button> <button type="submit">Update Tour</button>
</form> </form>
</main> </main>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment