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 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 046dc0a..b483320 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); - ?> @@ -68,6 +66,39 @@ $categories = getCategories($db); + Ajouter un Évènement
+
+ +
+ +

+ + +
+ +
+ +
+
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));