Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>MCQ Questions</title>
- </head>
- <body>
- <?php
- session_start();
- //echo "type" . $_SESSION["type"] . ".<br>";
- $dbh = new PDO('mysql:host=174.138.75.54;dbname=airman_handbook', 'airman', 'airman12345');
- $type = $_SESSION["type"];
- ?>
- <form method="post" action="uploadQuestion.php" enctype="multipart/form-data">
- <p> Enter the question :</p> <input name="question" type="text"> <br><br>
- Select question type : <br><br>
- <div id="types">
- SSgt <input name="type" type="radio" id="t2" value="1" <?=($type==1?"checked":"");?> >
- TSgt <input name="type" type="radio" id="t1" value="2" <?=($type==2?"checked":"");?>>
- MSgt <input name="type" type="radio" id="t3" value="3" <?=($type==3?"checked":"");?>>
- </div>
- <p> Enter options :</p>
- Enter option 1 : <input name="opt1" type="text"> <br><br>
- Enter option 2 : <input name="opt2" type="text"> <br><br>
- Enter option 3 : <input name="opt3" type="text"> <br><br>
- Enter option 4 : <input name="opt4" type="text"> <br><br>
- <p> Enter correct answer :</p>
- <input name="ans" type="input"> <br><br>
- Select chapter :
- <select name="chapters">
- <?php $type = document.querySelector('input[name = "type"]:checked').value;
- echo($type);
- ?>
- <?php
- $stmt = $dbh->prepare("SELECT * FROM chapters where type = $type" );
- $stmt->execute();
- $results = $stmt->fetchall(PDO::FETCH_ASSOC);
- if(count($results > 0)){
- foreach($results as $row):?>
- <option value="<?php echo $row['id'];?>"><?php echo $row['title'];?></option>
- <?php
- endforeach;
- }else{?>
- <option value="0">No data found</option>
- <?php
- }
- ?>
- </select> <br><br>
- <input type="submit" value = "Submit">
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement