|
|
@@ -61,10 +61,12 @@
|
|
|
$sql = "SELECT * FROM gamePlayers WHERE gameId = $gameId";
|
|
|
$result = $conn->query($sql);
|
|
|
$done = true;
|
|
|
+ $playerIds = array();
|
|
|
while ($data = $result->fetch_assoc()) {
|
|
|
if ($data['status'] != "ACCEPTED") {
|
|
|
echo $data['status'];
|
|
|
$done = false;
|
|
|
+ $playerId[] = $data['playerId'];
|
|
|
}
|
|
|
}
|
|
|
if ($done) {
|
|
|
@@ -73,6 +75,18 @@
|
|
|
if (!$result) {
|
|
|
echo "updating game status active failed " . $conn->error;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ $questionSql = "SELECT id FROM questions ORDER BY RAND() LIMIT 1";
|
|
|
+ $questionIdResult = $conn->query($questionSql);
|
|
|
+ $data = $questionIdResult->fetch_assoc();
|
|
|
+ $values = "";
|
|
|
+ foreach ($playerIdsArray AS $playerId) {
|
|
|
+ $values .= "($gameId, (SELECT name FROM users WHERE id = $playerId), " . $data['id'] . "),"
|
|
|
+ }
|
|
|
+ $values = rtrim($values, ",");
|
|
|
+ $insertRandomStartQuestion = "INSERT INTO userLockedQuestions (gameId, playerName, questionId) VALUES $values";
|
|
|
+ $conn->query($insertRandomStartQuestion);
|
|
|
}
|
|
|
}
|
|
|
} else if ($callFunction === "SetLastPlayed") {
|