Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. <?php
  2.  
  3. $sql = "SELECT Q_body, Q_ID FROM s_evaluation_questions WHERE Ev_ID='1'";
  4. $result = $conn->query($sql);
  5.  
  6. ?>
  7.  
  8. <?php
  9.  
  10. if ($result->num_rows > 0)
  11. {
  12.  
  13. ?>
  14. <form action="AnswerS.php" method="POST">
  15. <table align="right" id="keywords" cellspacing="0" cellpadding="0">
  16. <thead>
  17. <tr>
  18. <th colspan="4"> </th>
  19. <th>Question</th>
  20. </tr>
  21. </thead>
  22.  
  23. <tbody>
  24. <?php
  25. while($row = $result->fetch_assoc())
  26. { $answer="s".$row["Q_ID"];
  27. ?>
  28. <tr>
  29. <td>
  30. <input type="hidden" name="Q_ID" value="<?php echo $row["Q_ID"]; ?>" >
  31. <input type="radio" name=<?php echo $answer?> value="Bad" >Bad
  32. <input type="radio" name=<?php echo $answer?> value="Good"> Good
  33. <input type="radio" name=<?php echo $answer?> value="VeryGood"> Very Good
  34. <input type="radio" name=<?php echo $answer?> value="Excellent"> Excellent</td>
  35. <td align="right"> <?php echo $row["Q_body"]?></td>
  36. </tr>
  37.  
  38. <?php } ?>
  39.  
  40. </tbody>
  41.  
  42. </table></br></br></br></br></br></br></br>
  43. <input type="submit" value="Send" />
  44. </form>
  45. <?php
  46.  
  47. ?></div>
  48. <?php
  49. } else
  50. {echo "not allowed";}
  51.  
  52.  
  53. and on the AnswerS.php page I suppose to store the answers on db as the following:
  54. $UID='1';
  55. $answer=$_POST['answer'];
  56. $Q_ID= $_POST['Q_ID'];
  57.  
  58.  
  59. $sql = "INSERT INTO s_evaluation_answers(Q_ID, A_body, UID) VALUES($Q_ID, $answer, $UID) ";
  60. $result = $conn->query($sql);
  61.  
  62. if ($result === TRUE) {
  63. echo "done" ;
  64. }
  65. else {
  66. echo "Error: " . $sql . "<br>" . $conn->error;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement