Tengo problema (no se como hacer un UPDATE) a la hora de actulizar la ficha del alumno ya que solo me cambia el nombre y imagen del alumno, y lo que quiero hacer es añadir o quitar los cursos en el que esta inscrito desde un select multiple.
Esta es una captura del archivo edit:
http://127.0.0.1/php/edit_student.php?id=2
Tabla Alumnos
--------------------------------------------- - student_id - student_name - student_image - --------------------------------------------- - 1 - Ana - avatar.jpg - - 2 - David - avatar.jpg - - 3 - Jasmine - avatar.jpg - ---------------------------------------------
Tabla Cursos
------------------------------------------- - course_id - course_title - course_image - ------------------------------------------- - 7 - Photoshop - image.jpg - - 8 - Cinema 4D - image.jpg - - 9 - Idesign - image.jpg - - 10 - Illustrator - image.jpg - -------------------------------------------
Tabla Alumnos_Cursos
---------------------------------------------- students_courses_id - course_id - student_id - ---------------------------------------------- - 1 - 7 - 1 - 2 - 8 - 2 - 3 - 9 - 2 - 4 - 10 - 3 - 5 - 8 - 1 ----------------------------------------------
Mi codigo
$connect = connect($database); if(!$connect){ header ('Location: ' . SITE_URL . '/controller/error.php'); }if ($_SERVER['REQUEST_METHOD'] == 'POST'){
$statment = $connect->prepare( 'UPDATE students SET student_name = :student_name, student_image = :student_image WHERE student_id = :student_id' ); $statment->execute(array( ':student_name' => $student_name, ':student_image' => $student_image, ':student_id' => $student_id )); $statment = $connect->prepare( 'UPDATE students_courses SET course_id = :course_id WHERE student_id ='.$student_id) ; $statment->execute();$course_id = $_POST['course_id']; $student_id = cleardata($_POST['student_id']); $student_name = cleardata($_POST['student_name']); $student_image_save = $_POST['student_image_save']; $student_image = $_FILES['student_image']; if (empty($student_image['name'])) { $student_image = $student_image_save; } else{ $student_image_upload = '../' . $items_config['images_folder'] . $_FILES['student_image']['name']; move_uploaded_file($_FILES['student_image']['tmp_name'], $student_image_upload); $student_image = $_FILES['student_image']['name']; }