This repository has been archived by the owner on May 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.php
101 lines (90 loc) · 3.2 KB
/
list.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
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
<?php
/*error_reporting(E_ALL);
ini_set("display_errors", 1);
- 그냥 접속하면 완료된 게임 중에 하나 랜덤 출력
- $_GET['room'] 있으면 해당 게임 출력
*/
$php_filename = basename(__FILE__);
$title = "그림-그림";
include_once("header.php");
require_once 'conn.php';
global $mysqli;
?>
<div class="jumbotron">
<?php
$query = "SELECT room_id FROM gameRoom WHERE room_order = 0";
$result = $mysqli->query($query);
for($i=0; $i<$result->num_rows; $i++) {
$gameRoom = $result->fetch_assoc();
echo "<a href='list.php?room=".$gameRoom['room_id']."'>".$gameRoom['room_id']."</a> ";
}
?>
</div>
<div style="text-align: center;">
<?php
if(isset($_GET['room'])) {
$query = "SELECT * FROM gameRoom WHERE room_id = {$_GET['room']} and room_order=0";
$result = $mysqli->query($query);
if ($result->num_rows > 0) {
$gameRoom = $result->fetch_assoc();
$query = "select * from word where word_id='".$gameRoom['room_word_id']."'";
$result = $mysqli->query($query);
$data = $result->fetch_assoc();
$word = $data['word_data'];
$query = "SELECT * FROM gamePlay WHERE play_room_id = ".$gameRoom['room_id']." ORDER BY gamePlay.play_room_order ASC";
$result = $mysqli->query($query);
$i = 0;
$gamePlay = array();
while($data = mysqli_fetch_assoc($result)){
$gamePlay[$i]['play_room_order'] = $data['play_room_order'];
$gamePlay[$i]['play_data'] = $data['play_data'];
$i++;
}
echo "<h2>".$word."</h2><br><br>";
for($i=0; $i<$result->num_rows; $i++) {
//echo $gamePlay[$i]['play_room_order']."<br>";
if($i % 2 == 0) {
echo "<img src='/upload/".$gamePlay[$i]['play_data']."' width='auto' height='300px'><br><br>";
} else {
echo "<h2>".$gamePlay[$i]['play_data']."</h2><br><br>";
}
}
} else {
echo "<script language='javascript'>
alert('아직 진행 중인 게임입니다.');
</script>";
}
} else {
$query = "SELECT * FROM gameRoom WHERE room_order = 0";
$result = $mysqli->query($query);
$random = mt_rand(0, $result->num_rows-1);
$result->data_seek($random);
$gameRoom = $result->fetch_assoc();
$query = "select * from word where word_id='".$gameRoom['room_word_id']."'";
$result = $mysqli->query($query);
$data = $result->fetch_assoc();
$word = $data['word_data'];
$query = "SELECT * FROM gamePlay WHERE play_room_id = ".$gameRoom['room_id']." ORDER BY gamePlay.play_room_order ASC";
$result = $mysqli->query($query);
$i = 0;
$gamePlay = array();
while($data = mysqli_fetch_assoc($result)){
$gamePlay[$i]['play_room_order'] = $data['play_room_order'];
$gamePlay[$i]['play_data'] = $data['play_data'];
$i++;
}
echo "<h2>{$word}</h2><br><br>";
for($i=0; $i<$result->num_rows; $i++) {
//echo $gamePlay[$i]['play_room_order']."<br>";
if($i % 2 == 0) {
echo "<img src='/upload/".$gamePlay[$i]['play_data']."' width='auto' height='300px'><br><br>";
} else {
echo "<h2>".$gamePlay[$i]['play_data']."</h2><br><br>";
}
}
}
$result->close();
$mysqli->close();
?>
</div>
<?php include_once("footer.php"); ?>