Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html>
- <head>
- <title>Questions</title>
- </head>
- <body>
- <form method="post" action="deleteQuestions.php" enctype="multipart/form-data">
- <style>
- td {
- text-align: left;
- }
- </style>
- Select rank :
- <select name="type" id="type" onchange="this.form.submit()">
- <?php if(isset($_POST['type']))
- { ?>
- <option value="1" <?php echo($_POST['type']==1?"selected":"");?>>SSgt</option>
- <option value="2" <?php echo($_POST['type']==2?"selected":"");?>>TSgt</option>
- <option value="3" <?php echo($_POST['type']==3?"selected":"");?>>MSgt</option>
- </select>
- <br><br>
- <?php
- }
- else
- {
- ?>
- <option value="1">SSgt</option>
- <option value="2">TSgt</option>
- <option value="3">MSgt</option>
- </select>
- <br><br>
- <?php
- }
- ?>
- <table id="example" style="width:50%">
- <tr>
- <th><font size="5">Questions</font></th>
- </tr>
- <?php
- ini_set('display_errors', 1);
- error_reporting(1);
- ini_set('error_reporting', E_ALL);
- $dbh = new PDO('mysql:host=17475.54;dbname=a', 'airman', 'a5');
- if(isset($_POST['type']))
- {
- $stmt = $dbh->prepare("SELECT * FROM questions where type = :type");
- $stmt->bindParam("type", $_POST['type']);
- $stmt->execute();
- $results = $stmt->fetchall(PDO::FETCH_ASSOC);
- }
- else{
- $stmt = $dbh->prepare("SELECT * FROM questions");
- $stmt->execute();
- $results = $stmt->fetchall(PDO::FETCH_ASSOC);
- }
- foreach($results as $que)
- {
- ?>
- <tr>
- <td><?php echo $que['question'];?></td>
- <td><input type="submit" id="<?php echo $chapter['id']?>" name="action" value="Delete<?php echo $que['id']?>">
- <input type="hidden" name="id" value="<?php echo $que['id']?>" />
- </tr>
- <?php
- }
- ?>
- </table>
- </body>
- <?php
- if(isset($_POST['action'])) {
- ini_set('display_errors', 1);
- error_reporting(1);
- ini_set('error_reporting', E_ALL);
- $stmt = $dbh->prepare("DELETE FROM `questions` WHERE `id`= " . $_POST['id']);
- $stmt->execute();
- $result = $stmt->fetch(PDO::FETCH_ASSOC);
- if(count($result) > 0)
- {
- echo 'row deleted';
- ?>
- <?php
- }
- else{
- echo 'row could not delete';
- }
- }
- else{
- echo 'not deleted';
- }
- ?>
- </form>
- </html>
- <?php
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement