-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsert_dummy_data.php
More file actions
39 lines (32 loc) · 1.37 KB
/
insert_dummy_data.php
File metadata and controls
39 lines (32 loc) · 1.37 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
<?php
require_once "config_gameinfo.php";
$conn = new mysqli($servername, $username, $password, $dbname_game);
$sql = "CREATE TABLE IF NOT EXISTS leaderboard(
pkey INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
`login` VARCHAR(30) NOT NULL,
`total_games` INT(10) NOT NULL,
`wins` INT(5) NOT NULL,
`time_played` INT(10) NOT NULL,
`turn_count` INT(10) NOT NULL
)";
$sql = 'SELECT * FROM leaderboard WHERE `login`="dummy1"';
$result = $conn->query($sql);
if($result->num_rows == 0){
//if table is empty, populate with dummy data
$dum1 = 'INSERT INTO `leaderboard`(`login`, `total_games`, `wins`, `time_played`, `turn_count`) VALUES
("dummy1", 869, 5, 20000, 10000)'; //max total games
$conn->query($dum1);
$dum2 = 'INSERT INTO `leaderboard`(`login`, `total_games`, `wins`, `time_played`, `turn_count`) VALUES
("dummy2", 758, 645, 20426, 12736)'; //max wins
$conn->query($dum2);
$dum3 = 'INSERT INTO `leaderboard`(`login`, `total_games`, `wins`, `time_played`, `turn_count`) VALUES
("dummy3", 25, 10, 69000, 500)'; //max time played
$conn->query($dum3);
$dum4 = 'INSERT INTO `leaderboard`(`login`, `total_games`, `wins`, `time_played`, `turn_count`) VALUES
("dummy4", 416, 0, 34584, 17473)'; //max turn count
$conn->query($dum4);
}
else{
echo "Error dummy data already exists in database: " . $conn->error ."<br>";
}
?>