Advertisement
Guest User

Untitled

a guest
Nov 29th, 2016
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.26 KB | None | 0 0
  1. <?php
  2.  
  3. $servername = "mysql-server-1.macs.hw.ac.uk";
  4. $username = "cam2";
  5. $password = "abccam2354";
  6. $dbname = "cam2";
  7.  
  8. // Create connection
  9. $conn = new mysqli($servername, $username, $password, $dbname);
  10. // Check connection
  11. if ($conn->connect_error) {
  12. die("Connection failed: " . $conn->connect_error);
  13. }
  14. ?>
  15.  
  16.  
  17. <!DOCTYPE html>
  18. <html>
  19. <head>
  20.  
  21.  
  22. <style>
  23. div.container {
  24. width: 100%;
  25. border: 1px solid gray;
  26. }
  27.  
  28. header, footer {
  29. padding: 1em;
  30. color: white;
  31. background-color: blue;
  32. clear: left;
  33. text-align: center;
  34. }
  35.  
  36. nav {
  37. float: left;
  38. max-width: 160px;
  39. margin: 0;
  40. padding: 1em;
  41. }
  42.  
  43. nav ul {
  44. list-style-type: none;
  45. padding: 0;
  46. }
  47.  
  48. nav ul a {
  49. text-decoration: none;
  50. }
  51.  
  52. article {
  53. margin-left: 170px;
  54. border-left: 1px solid gray;
  55. padding: 1em;
  56. overflow: hidden;
  57. }
  58.  
  59. * {
  60. box-sizing: border-box;
  61. }
  62. #count {
  63. background: #9F0;
  64. width: 10%;
  65. height: 100px;
  66. text-align: center;
  67. line-height: 100px;
  68. font-size: 64px;
  69. margin: 0;
  70. border: 3px solid green;
  71. border-radius: 5px;
  72. }
  73.  
  74. .button {
  75. background: #09F;
  76. width: 5%;
  77. height: 50px;
  78. text-align: center;
  79. line-height: 50px;
  80. font-size: 32px;
  81. border: 3px solid blue;
  82. border-radius: 5px;
  83. }
  84.  
  85. .button, #count {
  86. float: left;
  87. }
  88.  
  89. #minus {
  90. margin: 25px 2.5% 0 37.5%;
  91. }
  92.  
  93. #plus {
  94. margin: 25px 37.5% 0 2.5%;
  95. }
  96.  
  97. </style>
  98. </head>
  99. <body>
  100.  
  101. <div class="container">
  102.  
  103. <header>
  104. <h1>Calum's Really Shitty Website</h1>
  105. </header>
  106.  
  107. <nav>
  108. <ul>
  109. <li><a href="#">Athletics</a></li>
  110. <li><a href="#">Football</a></li>
  111. <li><a href="#">Snooker</a></li>
  112. </ul>
  113. </nav>
  114.  
  115. <article>
  116. <h1>All Q&A's</h1>
  117.  
  118. <p>Add New Movie</p>
  119.  
  120. <form method = "post">
  121.  
  122.  
  123. </p>
  124. <input type="hidden" name="user" size="15"
  125. maxlength="30" value = "<?php echo $user ?>"/>
  126. <input type="hidden" name="pass" size="15"
  127. maxlength="30" value = "<?php echo $pass ?>"/> </p>
  128.  
  129.  
  130. <button id = "button" type="button">Ask Question</button>
  131. </br></br>
  132. <div id = "id1" style="display: none;">
  133.  
  134.  
  135.  
  136.  
  137. <p>Title</p>
  138. <textarea id = "questiontitle" name="questiontitle" cols="60" rows="1"></textarea>
  139. <p>Question Type</p>
  140. <textarea id="Question Type" name="questiontype"></textarea>
  141. </br><p>Question</p>
  142. <textarea id = "questionarea" name="questionarea" cols="60" rows="10"></textarea></br>
  143. <input type="hidden" name="questionType" id="questionType" value= "HTML" />
  144. <input type="submit" name="submitquestion" class = "submitquestion"
  145. value="Submit" />
  146.  
  147. <br>
  148.  
  149.  
  150. <p class="button" id="minus">-</p>
  151. <p id="count">0</p>
  152. <p class="button" id="plus">+</p>
  153.  
  154.  
  155.  
  156.  
  157. <script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
  158. <script >
  159. var counter = 0;
  160.  
  161. $("#plus").click(function(){
  162. counter++;
  163. $("#count").text(counter);
  164. });
  165.  
  166. $("#minus").click(function(){
  167. counter--;
  168. $("#count").text(counter);
  169. });s
  170. </script>
  171.  
  172. </div>
  173.  
  174. <script>
  175. var button = document.getElementById('button');
  176.  
  177. button.onclick = function() {
  178. var div = document.getElementById('id1');
  179. if (div.style.display !== 'none') {
  180. div.style.display = 'none';
  181. }
  182. else {
  183. div.style.display = 'block';
  184. }
  185. };
  186.  
  187. </script>
  188.  
  189. </div>
  190.  
  191.  
  192. </form>
  193. <?php
  194.  
  195. session_start();
  196.  
  197. $userIDs = array();
  198. $movieIDs = array();
  199. $index = -1;
  200.  
  201. //$user = $_POST['user'];
  202. //$pass = $_POST['pass'];
  203.  
  204.  
  205.  
  206. $result = mysqli_query($conn, "SELECT *
  207. FROM Answers");
  208.  
  209.  
  210. while($row = mysqli_fetch_array($result)) {
  211.  
  212. $index = $index + 1;
  213.  
  214. echo "<br/><br/>";
  215.  
  216. echo "<p id = '" . $row["QuestionsID"] . "a'> <b> Title : </b>" . $row["Question"]. "<b> Genre : </b> " . $row["Answer"]. "<b> Rating: </b>" . $row["Type"]. "</p>";
  217.  
  218.  
  219. //<p class="button" id="minus">-</p> //////was wanting to echo that everytime when i get a ebtry in database <-------
  220. //<p id="count">0</p>
  221. //<p class="button" id="plus">+</p>
  222.  
  223.  
  224.  
  225.  
  226. }
  227.  
  228. echo "</br></br>";
  229.  
  230. ?>
  231.  
  232. </article>
  233.  
  234. <footer>Calum McLean</footer>
  235.  
  236. </div>
  237.  
  238. </body>
  239. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement