-
Notifications
You must be signed in to change notification settings - Fork 0
/
view_result_processor.php
39 lines (32 loc) · 1.34 KB
/
view_result_processor.php
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
<?php
//include config for database, get connecton to the database $conn
require('database_config.php');
$userName = $_POST["userName"];
$query = "SELECT UserID FROM UserEntry WHERE UserName = '$userName'";
$result = $conn -> query($query);
if($result -> num_rows == 1){
$speedArray = new array();
$mistakeRateArray = new array();
$averageResponseArray = new array();
$averageRateArray = new array();
$row = $result -> fetch_assoc();
$userId = $row['UserID'];
$query = "SELECT Speed, Mistake, Respond FROM GeneralData WHERE UserID = '$userId' ORDER BY CreatedTime";
$result = $conn -> query($query);
while($row = $result -> fetch_assoc()){
$speedArray[] = $row['Speed'];
$mistakeRateArray[] = $row['Mistake'];
$averageResponseArray[] = $row['Respond'];
}
}
?>
$query = "SELECT * FROM DetailedData WHERE UserID = '$userId' AND KeyChar = '$key'";
$result = $conn -> query($query);
if($result -> num_rows > 20){
$query = "SELECT CreatedTime FROM DetailedData WHERE UserID = '$userId' AND KeyChar = '$key' ORDER BY CreatedTime ASC LIMIT 1";
$result = $conn -> query($query);
$row = $result -> fetch_assoc();
$firstDateTime = $row['CreatedTime'];
$query = "DELETE FROM DetailedData WHERE CreatedTime = '$firstDateTime' AND UserID = '$userId' AND KeyChar = '$key'";
$result = $conn -> query($query);
}