From 52ed0820621a6218598f8d9095d82c5e09cea236 Mon Sep 17 00:00:00 2001 From: AmarOk Date: Thu, 17 Mar 2016 09:45:01 +0100 Subject: [PATCH] check checkboxes --- databaseOperations.php | 7 ++++--- editEvent.php | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/databaseOperations.php b/databaseOperations.php index 22e5e1b..1c162c6 100755 --- a/databaseOperations.php +++ b/databaseOperations.php @@ -166,10 +166,11 @@ function getCategoriesForOneEvent($db, $eventId) { try { - $request = $db->prepare('SELECT cat_title FROM eventCategorie NATURAL JOIN categorie NATURAL JOIN sous_categorie WHERE event_id=?'); - $request->execute(array($id)); - $result = $request->fetch(); + $request = $db->prepare('SELECT cat_id FROM eventCategorie NATURAL JOIN categorie NATURAL JOIN sous_categorie WHERE event_id=?'); + $request->execute(array($eventId)); + $result = $request->fetchAll(); $request->closeCursor(); + for($i=0; $i < count($result); $i++) $result[$i] = $result[$i][0]; return $result; } catch(PDOException $e) diff --git a/editEvent.php b/editEvent.php index f8257f9..d34b11b 100644 --- a/editEvent.php +++ b/editEvent.php @@ -48,9 +48,11 @@ $event = getOneEvent($db, $id);
".$cats[$i][1]." "; + $checked = ''; + if(in_array(trim($cats[$i][0]), $catsForId)) $checked = 'checked'; + echo "".$cats[$i][1]." "; } ?>