Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>MCQ Questions</title>
  6. </head>
  7. <body>
  8.  
  9. <?php
  10. session_start();
  11. //echo "type" . $_SESSION["type"] . ".<br>";
  12.  
  13. $dbh = new PDO('mysql:host=174.138.75.54;dbname=airman_handbook', 'airman', 'airman12345');
  14.  
  15. $type = $_SESSION["type"];
  16. ?>
  17.  
  18. <form method="post" action="uploadQuestion.php" enctype="multipart/form-data">
  19. <p> Enter the question :</p> <input name="question" type="text"> <br><br>
  20. Select question type : <br><br>
  21.  
  22. <div id="types">
  23.  
  24. SSgt <input name="type" type="radio" id="t2" value="1" <?=($type==1?"checked":"");?> >
  25.  
  26. TSgt <input name="type" type="radio" id="t1" value="2" <?=($type==2?"checked":"");?>>
  27.  
  28. MSgt <input name="type" type="radio" id="t3" value="3" <?=($type==3?"checked":"");?>>
  29. </div>
  30.  
  31. <p> Enter options :</p>
  32. Enter option 1 : <input name="opt1" type="text"> <br><br>
  33. Enter option 2 : <input name="opt2" type="text"> <br><br>
  34. Enter option 3 : <input name="opt3" type="text"> <br><br>
  35. Enter option 4 : <input name="opt4" type="text"> <br><br>
  36.  
  37. <p> Enter correct answer :</p>
  38.  
  39. <input name="ans" type="input"> <br><br>
  40. Select chapter :
  41. <select name="chapters">
  42.  
  43. <?php $type = document.querySelector('input[name = "type"]:checked').value;
  44.  
  45. echo($type);
  46. ?>
  47.  
  48.  
  49. <?php
  50. $stmt = $dbh->prepare("SELECT * FROM chapters where type = $type" );
  51.  
  52. $stmt->execute();
  53. $results = $stmt->fetchall(PDO::FETCH_ASSOC);
  54.  
  55. if(count($results > 0)){
  56. foreach($results as $row):?>
  57. <option value="<?php echo $row['id'];?>"><?php echo $row['title'];?></option>
  58. <?php
  59. endforeach;
  60. }else{?>
  61.  
  62. <option value="0">No data found</option>
  63. <?php
  64. }
  65. ?>
  66.  
  67. </select> <br><br>
  68. <input type="submit" value = "Submit">
  69.  
  70. </form>
  71. </body>
  72. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement