-
Notifications
You must be signed in to change notification settings - Fork 0
/
message_box.php
146 lines (134 loc) ยท 3.74 KB
/
message_box.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>๋ฉ๋๋กฑ๋ํ</title>
<link rel="stylesheet" type="text/css" href="./css/common.css">
<link rel="stylesheet" type="text/css" href="./css/message.css">
<link rel="stylesheet" href="css/main1.css">
</head>
<body>
<header>
<?php include "header.php";?>
</header>
<section>
<div id="main_img_bar">
<img src="./img/main_img.png">
</div>
<div id="message_box">
<h3>
<?php
if (isset($_GET["page"]))
$page = $_GET["page"];
else
$page = 1;
$mode = $_GET["mode"];
if ($mode=="send")
echo "์ก์ ์ชฝ์งํจ > ๋ชฉ๋ก๋ณด๊ธฐ";
else
echo "์์ ์ชฝ์งํจ > ๋ชฉ๋ก๋ณด๊ธฐ";
?>
</h3>
<div>
<ul id="message">
<li>
<span class="col1">๋ฒํธ</span>
<span class="col2">์ ๋ชฉ</span>
<span class="col3">
<?php
if ($mode=="send")
echo "๋ฐ์์ด";
else
echo "๋ณด๋ธ์ด";
?>
</span>
<span class="col4">๋ฑ๋ก์ผ</span>
</li>
<?php
$con = mysqli_connect("localhost", "user1", "12345", "sample");
if ($mode=="send")
$sql = "select * from message where send_id='$userid' order by num desc";
else
$sql = "select * from message where rv_id='$userid' order by num desc";
$result = mysqli_query($con, $sql);
$total_record = mysqli_num_rows($result); // ์ ์ฒด ๊ธ ์
$scale = 10;
// ์ ์ฒด ํ์ด์ง ์($total_page) ๊ณ์ฐ
if ($total_record % $scale == 0)
$total_page = floor($total_record/$scale);
else
$total_page = floor($total_record/$scale) + 1;
// ํ์ํ ํ์ด์ง($page)์ ๋ฐ๋ผ $start ๊ณ์ฐ
$start = ($page - 1) * $scale;
$number = $total_record - $start;
for ($i=$start; $i<$start+$scale && $i < $total_record; $i++)
{
mysqli_data_seek($result, $i);
// ๊ฐ์ ธ์ฌ ๋ ์ฝ๋๋ก ์์น(ํฌ์ธํฐ) ์ด๋
$row = mysqli_fetch_array($result);
// ํ๋์ ๋ ์ฝ๋ ๊ฐ์ ธ์ค๊ธฐ
$num = $row["num"];
$subject = $row["subject"];
$regist_day = $row["regist_day"];
if ($mode=="send")
$msg_id = $row["rv_id"];
else
$msg_id = $row["send_id"];
$result2 = mysqli_query($con, "select name from members where id='$msg_id'");
$record = mysqli_fetch_array($result2);
$msg_name = $record["name"];
?>
<li>
<span class="col1"><?=$number?></span>
<span class="col2"><a href="message_view.php?mode=<?=$mode?>&num=<?=$num?>"><?=$subject?></a></span>
<span class="col3"><?=$msg_name?>(<?=$msg_id?>)</span>
<span class="col4"><?=$regist_day?></span>
</li>
<?php
$number--;
}
mysqli_close($con);
?>
</ul>
<ul id="page_num">
<?php
if ($total_page>=2 && $page >= 2)
{
$new_page = $page-1;
echo "<li><a href='message_box.php?mode=$mode&page=$new_page'>โ ์ด์ </a> </li>";
}
else
echo "<li> </li>";
// ๊ฒ์ํ ๋ชฉ๋ก ํ๋จ์ ํ์ด์ง ๋งํฌ ๋ฒํธ ์ถ๋ ฅ
for ($i=1; $i<=$total_page; $i++)
{
if ($page == $i) // ํ์ฌ ํ์ด์ง ๋ฒํธ ๋งํฌ ์ํจ
{
echo "<li><b> $i </b></li>";
}
else
{
echo "<li> <a href='message_box.php?mode=$mode&page=$i'> $i </a> <li>";
}
}
if ($total_page>=2 && $page != $total_page)
{
$new_page = $page+1;
echo "<li> <a href='message_box.php?mode=$mode&page=$new_page'>๋ค์ โถ</a> </li>";
}
else
echo "<li> </li>";
?>
</ul> <!-- page -->
<ul class="buttons">
<li><button onclick="location.href='message_box.php?mode=rv'">์์ ์ชฝ์งํจ</button></li>
<li><button onclick="location.href='message_box.php?mode=send'">์ก์ ์ชฝ์งํจ</button></li>
<li><button onclick="location.href='message_form.php'">์ชฝ์ง ๋ณด๋ด๊ธฐ</button></li>
</ul>
</div> <!-- message_box -->
</section>
<footer>
<?php include "footer.php";?>
</footer>
</body>
</html>