<?php
$query = "select courses.id, courses.title, courses.category_id, courses.description, courses.start_date, courses.end_date, courses.image, courses.location, courses.published, course_category.title as category, trainers.name as trainer from courses
LEFT JOIN course_category ON courses.category_id = course_category.id
LEFT JOIN trainers ON courses.trainer_id = trainers.id
order by courses.id DESC";
$courses = $traininovate->fetchAllData($query, $con);
if (isset($_GET['delete'])) {
$course_id = $_GET['delete']; // course id
$query = "DELETE FROM COURSES WHERE id = $course_id";
$traininovate->deleteRow($query, $con);
$query = "DELETE FROM open_attendance WHERE course_id = $course_id";
$traininovate->deleteRow($query, $con);
$query = "DELETE FROM course_materials WHERE course_id = $course_id";
$traininovate->deleteRow($query, $con);
$query = "DELETE FROM course_attendance WHERE course_id = $course_id";
$traininovate->deleteRow($query, $con);
$query = "DELETE FROM course_evaluation WHERE course_id = $course_id";
$traininovate->deleteRow($query, $con);
header("location: courseslist.php");
}
?>
Asked
Active
Viewed 39 times
0

RiggsFolly
- 93,638
- 21
- 103
- 149

Ahmed Younes
- 1
- 2
-
Any error messages? Any checking for errors anywhere in the code you dont show us? – RiggsFolly May 09 '22 at 09:19
-
AA No,, i can post a screen shot if u want – Ahmed Younes May 09 '22 at 09:24
-
https://www.linkpicture.com/q/Screenshot-2022-05-09-112658.png – Ahmed Younes May 09 '22 at 09:27
-
WHat purpose does the initial SELECT query serve to this code – RiggsFolly May 09 '22 at 09:53
-
1Show us a `var_dump($_GET)` please – RiggsFolly May 09 '22 at 09:54
-
No syntax error – Ahmed Younes May 09 '22 at 09:54
-
1It would also be useful to see the HTML form that is launching this code – RiggsFolly May 09 '22 at 09:57
-
alright my mistake – Ahmed Younes May 09 '22 at 09:59
-
1hi ahmed, welcome to stackoverflow. have you take a [tour] and learn [ask]? those being said, you need to narrow down the problem first. see if its originated from the html form not passing correct `course_id`. it can also be how you execute query, may we know what is this `deleteRow` function defined? – Bagus Tesa May 09 '22 at 09:59
-
to be honest im not very good with codes im still learning ,, so i think i copied it from a example code and some line from others and i used my database files names – Ahmed Younes May 09 '22 at 10:06
-
Are you using the `mysqli_` or `PDO` extension to access your database? If you are not sure than show us the script the connects to the database – RiggsFolly May 09 '22 at 10:08
-
myqli . ....... – Ahmed Younes May 09 '22 at 10:17
-
To get errors out of PHP _even in a LIVE environment_ add these 4 lines **temporarily, while debugging**, to the top of any `MYSQLI_` based script you want to debug `ini_set('display_errors', 1); ini_set('log_errors',1); error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);`. This will force any `MYSQLI_` errors to generate an Exception that you can see on the browser as well as normal PHP errors. – RiggsFolly May 09 '22 at 10:24