Плз решить эту удалить не получится
student.php
<?php class Student { public function __construct() { $hostname = 'localhost'; $username = 'root'; $password = ''; $database = 'db_ci_batch21'; $this->conn = new mysqli($hostname, $username, $password, $database); if(!$this->conn) { die("not connected"); } } public function save_student($data) { $sql = "INSERT INTO tbl_student(student_name, email_address, mobile_number)VALUES('$data[student_name]', '$data[email_address]', '$data[mobile_number]')"; if($this->conn->query($sql)) { $message = "Save data successfully"; return $message; } else { $message = "Data not saved"; return $message; exit; } } public function select_all_student() { $sql = "SELECT * FROM tbl_student"; $result = $this->conn->query($sql); //echo '<pre>'; //print_r($result); //exit; return $result; } public function view_student() { } public function edit_student() { } public function delete_student($student_id) { $sql = "DELETE FROM tbl_student WHERE student_id = '$student_id'"; $this->conn->query($sql); header('Location: view_student.php'); } } ?>
view_student.php
<?php require '../mvc/student.php'; $obj = new Student(); $result = $obj->select_all_student(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Add student info <table><tbody><tr> <td> <a href="add_student.php">Add student</a> | <a href="view_student.php">View student</a> <h3>All student</h3> </td> </tr> </tbody></table> <?php while($row = $result->fetch_assoc()) { ?> <?php } ?> <table border="1" align="center"><tbody><tr> <th>Id</th> <th>Student name</th> <th>Email address</th> <th>Mobile number</th> <th>Action</th> </tr><tr> <td><?php echo $row['student_id'] ?></td> <td><?php echo $row['student_name'] ?></td> <td><?php echo $row['email_address'] ?></td> <td><?php echo $row['mobile_number'] ?></td> <td> <a href="">Edit</a> | <a href="delete.php?id = <?php echo $row['student_id'] ?>">Delete</a> </td> </tr></tbody></table>
delete.php
<?php require "../mvc/student.php"; $obj = new Student(); $student_id = $_GET['id']; //echo $student_id; $obj->delete_student($student_id); ?>
Что я уже пробовал:
решите проблему с действием удаления