Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function connectToDB()
- {
- try
- {
- $bdd = new PDO('mysql:host=localhost;dbname=test;charset=utf8', 'root', 'aswane7194');
- }
- catch(Exception $e)
- {
- die('Erreur : '.$e->getMessage());
- }
- }
- function listChallWebServeur($idchallenge)
- {
- try
- {
- $bdd = new PDO('mysql:host=localhost;dbname=test;charset=utf8', 'root', 'aswane7194');
- }
- catch(Exception $e)
- {
- die('Erreur : '.$e->getMessage());
- }
- $reponse = $bdd->query("SELECT name, description FROM challenge WHERE categorie = 'web-serveur'");
- while($donnes = $reponse->fetch())
- {
- $arrayChallName[] = $donnes["name"];
- }
- if(array_key_exists($idchallenge, $arrayChallName))
- {
- echo $arrayChallName[$idchallenge];
- }
- }
- function scoreWebServeur($idchallenge)
- {
- try
- {
- $bdd = new PDO('mysql:host=localhost;dbname=test;charset=utf8', 'root', 'aswane7194');
- }
- catch(Exception $e)
- {
- die('Erreur : '.$e->getMessage());
- }
- $reponse = $bdd->query("SELECT score FROM challenge WHERE categorie = 'web-serveur'");
- while($donnes = $reponse->fetch())
- {
- $arrayChallScore[] = $donnes["score"];
- }
- if (array_key_exists($idchallenge, $arrayChallScore))
- {
- echo $arrayChallScore[$idchallenge];
- }
- }
- function difficulteWebServeur($idchallenge)
- {
- try
- {
- $bdd = new PDO('mysql:host=localhost;dbname=test;charset=utf8', 'root', 'aswane7194');
- }
- catch(Exception $e)
- {
- die('Erreur : '.$e->getMessage());
- }
- $reponse = $bdd->query("SELECT difficulté FROM challenge WHERE categorie = 'web-serveur'");
- while($donnes = $reponse->fetch())
- {
- $arrayChallDifficulte[] = $donnes['difficulté'];
- }
- if (array_key_exists($idchallenge, $arrayChallDifficulte))
- {
- echo $arrayChallDifficulte[$idchallenge];
- }
- else{
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement