Guest User

Untitled

a guest
Mar 29th, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Infinitive Link - Conjugator</title>
  5.  
  6. <link href="style.css" rel="stylesheet">
  7. <link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
  8.  
  9. <script src="jquery.js" type="text/javascript"></script>
  10.  
  11. </head>
  12. <body>
  13. <div id="wrapper">
  14.  
  15. <div class="title"><h2>Infinitive Link</h2></div>
  16. <div class="flagbreak"></div>
  17.  
  18. <?php
  19.  
  20. $db = new mysqli('x', 'x', 'x', 'x');
  21.  
  22. if($db->connect_errno > 0){
  23. die('Unable to connect to database [' . $db->connect_error . ']');
  24. }
  25.  
  26. $sql = <<<SQL
  27. SELECT *
  28. FROM `infinitives`
  29. ORDER BY RAND()
  30. LIMIT 3
  31. SQL;
  32.  
  33. if(!$result = $db->query($sql)){
  34. die('There was an error running the query [' . $db->error . ']');
  35. }
  36.  
  37. $answer = rand(0, 2);
  38.  
  39. $english = array();
  40. $spanish = array();
  41.  
  42. while($row = $result->fetch_assoc()){
  43. array_push($english, $row['english']);
  44. array_push($spanish, $row['spanish']);
  45. }
  46. ?>
  47. <div id="questionwrapper">
  48. <p>
  49. Select the infinitive that means
  50. </p>
  51. <h4 class="answer">
  52. <?php
  53. echo $english[$answer];
  54. ?>
  55. </h4>
  56.  
  57. <div class="buttons">
  58. <?php
  59. for ($i = 0; $i < 3; $i++) {
  60. echo "<div class='button answerbutton' id='button-" . $i . "'>" . $spanish[$i] . "</div>";
  61. }
  62. ?>
  63. </div>
  64. </div>
  65.  
  66. <div id="correctwrapper">
  67. <p>&nbsp;</p>
  68. <h4>Correct!</h4>
  69. <div class="buttons">
  70. <div class="button againbutton">again</div>
  71. </div>
  72. </div>
  73.  
  74. <div id="incorrectwrapper">
  75. <p>&nbsp;</p>
  76. <h4>Incorrect!</h4>
  77. <p>The answer was: <?php echo $spanish[$answer]; ?></p>
  78. <div class="buttons">
  79. <div class="button againbutton">again</div>
  80. </div>
  81. </div>
  82.  
  83. <p>Developed by <a href="http://jamesmonger.com">James Monger</a></p>
  84.  
  85. <script type="text/javascript">
  86. <?php
  87. echo "var answer = " . $answer . ";";
  88. ?>
  89.  
  90. $('div.answerbutton').click(function() {
  91. $('div#questionwrapper').hide();
  92.  
  93. var id = ($( this ).attr('id')).replace("button-", "");
  94. if (id == answer) {
  95. $('div#correctwrapper').show();
  96. } else {
  97. $('div#incorrectwrapper').show();
  98. }
  99. });
  100.  
  101. $('div.againbutton').click(function() {
  102. location.reload();
  103. });
  104.  
  105. </script>
  106.  
  107. <script>
  108. (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  109. (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  110. m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  111. })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  112.  
  113. ga('create', 'UA-41920801-2', 'auto');
  114. ga('require', 'displayfeatures');
  115. ga('send', 'pageview');
  116.  
  117. </script>
  118.  
  119. </div>
  120. </body>
  121. </html>
Advertisement
Add Comment
Please, Sign In to add comment