when I click on the button ‘edit’ and ‘delete’, it does not show me the checklist/:id/card/:id . the IDs are not showing up. however, when i am in Mysql database, I am able to see the cards and delete it manually. so, i am not sure what the problem is…
// delete card
app.get('/deletecard/checklist/:checklist_ID/card/:id', (req, res) => {
const cardId = req.params.id;
const checklistId = req.params.checklist_ID;
const sql = 'DELETE FROM card_in_checklist WHERE Checklist_ID = ? AND id=?';
connection.query(sql, [checklistId,cardId], (error, results) => {
if (error) {
// handle any error that occurs during the database operation
console.error("Error deleting card: ", error);
res.status(500).send("Error deleting card");
} else {
// send a success response
res.redirect('/viewchecklist');
}
});
});
<!-- delete link -->
<a href= "/deletecard/checklist/<%= card_in_checklist[i].Checklist_ID %>/card/<%= card_in_checklist[i].id %>" class="btn btn-danger" onclick="return confirm('Are you sure you want to delete this card?')">Delete</a>
New contributor
user26362123 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.