Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. function connectToDB()
  5. {
  6. try
  7. {
  8. $bdd = new PDO('mysql:host=localhost;dbname=test;charset=utf8', 'root', 'aswane7194');
  9. }
  10. catch(Exception $e)
  11. {
  12. die('Erreur : '.$e->getMessage());
  13. }
  14. }
  15.  
  16. function listChallWebServeur($idchallenge)
  17. {
  18. try
  19. {
  20. $bdd = new PDO('mysql:host=localhost;dbname=test;charset=utf8', 'root', 'aswane7194');
  21. }
  22. catch(Exception $e)
  23. {
  24. die('Erreur : '.$e->getMessage());
  25. }
  26.  
  27. $reponse = $bdd->query("SELECT name, description FROM challenge WHERE categorie = 'web-serveur'");
  28.  
  29. while($donnes = $reponse->fetch())
  30. {
  31. $arrayChallName[] = $donnes["name"];
  32. }
  33. if(array_key_exists($idchallenge, $arrayChallName))
  34. {
  35. echo $arrayChallName[$idchallenge];
  36. }
  37. }
  38.  
  39. function scoreWebServeur($idchallenge)
  40. {
  41. try
  42. {
  43. $bdd = new PDO('mysql:host=localhost;dbname=test;charset=utf8', 'root', 'aswane7194');
  44. }
  45. catch(Exception $e)
  46. {
  47. die('Erreur : '.$e->getMessage());
  48. }
  49.  
  50. $reponse = $bdd->query("SELECT score FROM challenge WHERE categorie = 'web-serveur'");
  51.  
  52. while($donnes = $reponse->fetch())
  53. {
  54. $arrayChallScore[] = $donnes["score"];
  55. }
  56. if (array_key_exists($idchallenge, $arrayChallScore))
  57. {
  58. echo $arrayChallScore[$idchallenge];
  59. }
  60. }
  61.  
  62. function difficulteWebServeur($idchallenge)
  63. {
  64. try
  65. {
  66. $bdd = new PDO('mysql:host=localhost;dbname=test;charset=utf8', 'root', 'aswane7194');
  67. }
  68. catch(Exception $e)
  69. {
  70. die('Erreur : '.$e->getMessage());
  71. }
  72.  
  73. $reponse = $bdd->query("SELECT difficulté FROM challenge WHERE categorie = 'web-serveur'");
  74.  
  75. while($donnes = $reponse->fetch())
  76. {
  77. $arrayChallDifficulte[] = $donnes['difficulté'];
  78. }
  79. if (array_key_exists($idchallenge, $arrayChallDifficulte))
  80. {
  81. echo $arrayChallDifficulte[$idchallenge];
  82. }
  83. else{
  84.  
  85. }
  86. }
  87. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement