-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathanimal_screen.php
More file actions
122 lines (101 loc) · 3.11 KB
/
Copy pathanimal_screen.php
File metadata and controls
122 lines (101 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<!-- this is the animal screen -->
<!DOCTYPE html>
<html>
<head>
<title>DigiVet</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="http://code.jquery.com/jquery-latest.js"></script>
<?php
include 'functions.php';
refresh_database();
$con=null; //flush the database
?>
</head>
<body>
<div id="question">
<?php
include 'database.php';
$query = "SELECT * FROM table_general_question WHERE id_general_question = 1";
$sth = $con->prepare($query);
$sth->execute();
foreach ($sth->fetchAll() as $row) {
print "<p>" . $row['question'] . "</p>";
}
?>
</div>
<button class="play"></button>
<button class="pause"></button>
<form method="get">
<div id = "up_images">
<button id="cow" name ="button1" type = "submit" ></button>
<button id="goat" name ="button2" type = "submit" ></button>
<button id="sheep" name ="button3" type = "submit" ></button>
</div>
<div id = "down_images">
<button id="pig" name ="button4" type = "submit" ></button>
<button id="dog" name ="button5" type = "submit" ></button>
</div>
</form>
<?php
if(isset($_GET['button1'])){
$animal = 'cow';
$use_table = 'table_cow';
$stmt = $con->prepare("UPDATE variables_general SET kind_of_animal='$animal', use_table='$use_table'");
$stmt->execute();
$con=null;
header("Location: question.php"); //go to result page
exit;
} elseif(isset($_GET['button2'])) {
$animal = 'sheep';
$use_table = 'table_sheep';
$stmt = $con->prepare("UPDATE variables_general SET kind_of_animal='$animal', use_table='$use_table'");
$stmt->execute();
$con=null;
header("Location: question.php"); //go to result page
exit;
} elseif(isset($_GET['button3'])) {
$animal = 'goat';
$use_table = 'table_goat';
$stmt = $con->prepare("UPDATE variables_general SET kind_of_animal='$animal', use_table='$use_table'");
$stmt->execute();
$con=null;
header("Location: question.php"); //go to result page
exit;
} elseif(isset($_GET['button4'])) {
$animal = 'pig';
$use_table = 'table_pig';
$stmt = $con->prepare("UPDATE variables_general SET kind_of_animal='$animal', use_table='$use_table'");
$stmt->execute();
$con=null;
header("Location: question.php"); //go to result page
exit;
} elseif(isset($_GET['button5'])) {
$animal = 'dog';
$use_table = 'table_dog';
$stmt = $con->prepare("UPDATE variables_general SET kind_of_animal='$animal', use_table='$use_table'");
$stmt->execute();
$con=null;
header("Location: question.php"); //go to result page
exit;
}
?>
<script>
$(document).ready(function() {
var audioElement = document.createElement('audio');
audioElement.setAttribute('src', 'sounds/animal_type.mp3');
audioElement.setAttribute('autoplay', 'autoplay');
//audioElement.load()
$.get();
audioElement.addEventListener("load", function() {
audioElement.play();
}, true);
$('.play').click(function() {
audioElement.play();
});
$('.pause').click(function() {
audioElement.pause();
});
});
</script>
</body>
</html>