Browse Source

Merge branch 'master' of github.com:TheMrNomis/KiWi-calendar

master
AmarOk 10 years ago
parent
commit
494f3724cb
4 changed files with 87 additions and 3 deletions
  1. +48
    -0
      databaseOperations.php
  2. +1
    -0
      index.css
  3. +34
    -3
      index.php
  4. +4
    -0
      makedatabase.sql

+ 48
- 0
databaseOperations.php View File

@ -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 * @brief queries all the events from the database
* @param $db: the PDO connection to the database * @param $db: the PDO connection to the database


+ 1
- 0
index.css View File

@ -78,6 +78,7 @@ form
input[type="checkbox"] { input[type="checkbox"] {
display:none; display:none;
} }
input[type="checkbox"] + label span { input[type="checkbox"] + label span {
display:inline-block; display:inline-block;
width:19px; width:19px;


+ 34
- 3
index.php View File

@ -32,8 +32,6 @@ if(isset($_GET['w'])&&is_numeric($_GET['w']))
else else
$weekOffset = 0; $weekOffset = 0;
$categories = getCategories($db);
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
@ -68,6 +66,39 @@ $categories = getCategories($db);
+ Ajouter un Évènement + Ajouter un Évènement
</div></a> </div></a>
<div id="container"> <div id="container">
<form method="post" action="./update-categories.php">
<?php
for($tab = 0; $tab < 2; ++$tab)
{
$sous_categories = getSousCategories($db, $tab);
?>
<div id="tab<?php echo $tab; ?>" class="tabContent">
<?php
for($sous_cat_it = 0; $sous_cat_it < count($sous_categories); ++$sous_cat_it)
{
$sous_cat_id = $sous_categories[$sous_cat_it]['sous_cat_id'];
$sous_cat_titre = $sous_categories[$sous_cat_it]['sous_cat_titre'];
?>
<h2><?php echo $sous_cat_titre;?></h2>
<?php
$categories = getCategoriesBySousCategorie($db, $sous_cat_id);
for($cat_it = 0; $cat_it < count($categories); ++$cat_it)
{
$cat_id = $categories[$cat_it]['cat_id'];
$cat_titre = $categories[$cat_it]['cat_titre'];
?>
<input type="checkbox" id="cat_<?php echo $cat_id; ?>" name="cat_<?php echo $cat_id; ?>" />
<label for="cat_<?php echo $cat_id; ?>"><span></span><?php echo $cat_titre;?></label><br />
<?php
}
}
?>
</div>
<?php
}
?>
</form>
<!--
<h2>Conférences, Évènements</h2> <h2>Conférences, Évènements</h2>
<form name="confs" action="" method="POST"> <form name="confs" action="" method="POST">
<div align="left"><br> <div align="left"><br>
@ -103,7 +134,7 @@ $categories = getCategories($db);
<label for="c12"><span></span>Club rigolo</label><br> <label for="c12"><span></span>Club rigolo</label><br>
<br> <br>
</div> </div>
</form>
</form>-->
</div> </div>
</nav> </nav>


+ 4
- 0
makedatabase.sql View File

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

Loading…
Cancel
Save