From 406261e8df428aec52b4c1a01557e58dcc29c5d4 Mon Sep 17 00:00:00 2001 From: TheMrNomis Date: Thu, 3 Dec 2015 12:01:49 +0100 Subject: [PATCH 1/5] added some convenience functions for categories --- databaseOperations.php | 48 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/databaseOperations.php b/databaseOperations.php index d102b17..5d183b5 100755 --- a/databaseOperations.php +++ b/databaseOperations.php @@ -48,6 +48,54 @@ function getCategories($db) } } +/** + * @brief queries all the sub categories from a certain tab + * @param $db: the PDO connection to the database + * @param $tab: the ID of the tab + * @return a list of the subcategories for $tab + */ +function getSousCategories($db, $tab) +{ + try + { + $request = $db->prepare('SELECT * FROM sous_categorie WHERE sous_cat_tab = ? ORDER BY sous_cat_id ASC'); + $request->execute(array($tab)); + $result = $request->fetchAll(); + $request->closeCursor(); + return $result; + } + catch(PDOException $e) + { + //NOTE: change $e->getMessage() by an error message before going to production + echo($e->getMessage()); + die(); + } +} + +/** + * @brief queries all the categories from a subcategorie + * @param $db: the PDO connection to the database + * @param $sous_cat_id: the ID of the subcategorie + * @return a list of the categories for the subcategorie + */ +function getCategoriesBySousCategorie($db, $sous_cat_id) +{ + try + { + $request = $db->prepare('SELECT * FROM categorie WHERE sous_cat_id = ? ORDER BY cat_id ASC'); + $request->execute(array($sous_cat_id)); + $result = $request->fetchAll(); + $request->closeCursor(); + return $result; + } + catch(PDOException $e) + { + //NOTE: change $e->getMessage() by an error message before going to production + echo($e->getMessage()); + die(); + } +} + /** * @brief queries all the events from the database * @param $db: the PDO connection to the database From 79aee197e4b5888a70826980f09bd4585a9df223 Mon Sep 17 00:00:00 2001 From: TheMrNomis Date: Thu, 3 Dec 2015 12:02:03 +0100 Subject: [PATCH 2/5] loading categories from database --- index.php | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/index.php b/index.php index 2147d0c..7313549 100644 --- a/index.php +++ b/index.php @@ -32,8 +32,6 @@ if(isset($_GET['w'])&&is_numeric($_GET['w'])) else $weekOffset = 0; -$categories = getCategories($db); - ?> @@ -65,6 +63,40 @@ $categories = getCategories($db);
+ +
+ +
+ +

+ + +
+ +
+ +
+
From 74de9ee3f3afa05eb51382bafdd08d95b2d99fea Mon Sep 17 00:00:00 2001 From: TheMrNomis Date: Thu, 10 Dec 2015 09:20:05 +0100 Subject: [PATCH 3/5] checkbox styling --- index.css | 1 + index.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/index.css b/index.css index 02eecde..bf21b83 100755 --- a/index.css +++ b/index.css @@ -78,6 +78,7 @@ form input[type="checkbox"] { display:none; } + input[type="checkbox"] + label span { display:inline-block; width:19px; diff --git a/index.php b/index.php index bd38917..bb2b791 100644 --- a/index.php +++ b/index.php @@ -89,7 +89,7 @@ else $cat_titre = $categories[$cat_it]['cat_titre']; ?> -
+
Date: Thu, 10 Dec 2015 09:22:02 +0100 Subject: [PATCH 4/5] removed TODO message --- index.php | 1 - 1 file changed, 1 deletion(-) diff --git a/index.php b/index.php index bb2b791..3640132 100644 --- a/index.php +++ b/index.php @@ -66,7 +66,6 @@ else + Ajouter un Évènement
-
Date: Thu, 10 Dec 2015 09:25:19 +0100 Subject: [PATCH 5/5] comments in makedatabase --- makedatabase.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/makedatabase.sql b/makedatabase.sql index a761bf6..7abdee2 100644 --- a/makedatabase.sql +++ b/makedatabase.sql @@ -1,7 +1,11 @@ +-- categorie of the categorie CREATE TABLE sous_categorie(sous_cat_id INTEGER PRIMARY KEY, sous_cat_tab INTEGER NOT NULL, sous_cat_titre VARCHAR(255) NOT NULL); +-- categorie of the event CREATE TABLE categorie(cat_id INTEGER PRIMARY KEY, cat_titre VARCHAR(255) NOT NULL, sous_cat_id INTEGER NOT NULL, FOREIGN KEY(sous_cat_id) REFERENCES sous_categorie(sous_cat_id)); +-- event CREATE TABLE event(event_id INTEGER PRIMARY KEY, event_titre VARCHAR(255) NOT NULL, event_localisation VARCHAR(255) NOT NULL, event_dtstart DATETIME NOT NULL, event_dtend DATETIME NOT NULL, event_description TEXT NOT NULL, event_url VARCHAR(255) NULL); +-- table joining events to its categorie CREATE TABLE eventCategorie(event_id INTEGER, cat_id INTEGER, FOREIGN KEY(event_id) REFERENCES event(event_id), FOREIGN KEY(cat_id) REFERENCES categorie(cat_id));