SHARE
TWEET

Untitled

a guest Feb 7th, 2013 18 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $questions = array (
  4.    array("What is the most important part of a cooked breakfast?","Beans","Black pudding", "It's gotta be the soda bread"),
  5.    array("How are you today?","Fine","Not too bad","I'm grand sure!"),
  6.    array("The most important food group is","Proteins","Fats","Potatoes"),
  7.    array("The most beautiful smell on earth is:","A wee baby's head","Your mammy's cooking","A turf fire"),
  8.    array("Everyone is singing 'The Fields of Athenry' but you've forgotten the words. Do you:","Stop singing","Mime.","Wouldn't happen.")
  9.    );
  10.    
  11. //declare some variables
  12. $points = 0;;
  13. $answer1 = 0;
  14.  
  15. function initialQuestion($questions) {
  16.  
  17.         global $questions;
  18.         global $points;
  19.         global $answer1;
  20.  
  21.         $r = array_rand($questions);
  22.        
  23.         echo $questions[$r][0];
  24.  
  25.         echo "<form action='' method='post'>";
  26.         echo '<input type="submit" name="Answer1" onclick="" class="Answer" value="'.$questions[$r][1].'"><br>';
  27.         echo '<input type="submit" name="Answer2" onclick="" class="Answer" value="'.$questions[$r][2].'"><br>';
  28.         echo '<input type="submit" name="Answer3" onclick="" class="Answer" value="'.$questions[$r][3].'"><br>';
  29.         echo "</form>";
  30.        
  31.         unset($questions[$r]);
  32.        
  33.         echo count($questions);
  34.    
  35.         return $questions;//return this array
  36.    
  37.         echo "<br>";
  38.        
  39. }
  40.  
  41. initialQuestion($questions);
  42.  
  43. if (isset($_POST["Answer1"])){
  44.                 $points = $points + 20;
  45.                 $questions = initialQuestions($questions);
  46.         }
  47.  
  48. ?>
RAW Paste Data
Want to get better at PHP?
Learn to code PHP in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top