This repository has been archived by the owner on Nov 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
97 lines (92 loc) · 3.26 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>SSG_TONYs_WEB_BOARD</title>
<meta charset = 'utf-8'>
</head>
<style>
table{
border-top: 1px solid #444444;
border-collapse: collapse;
}
tr{
border-bottom: 1px solid #444444;
padding: 10px;
}
td{
border-bottom: 1px solid #efefef;
padding: 10px;
}
table .even{
background: #efefef;
}
.text{
text-align:center;
padding-top:20px;
color:#000000
}
.text:hover{
text-decoration: underline;
}
a:link {color : #57A0EE; text-decoration:none;}
a:hover { text-decoration : underline;}
</style>
<body>
<?php
$connect = mysqli_connect('localhost', 'ssg_board', 'ssg_tony', 'SSG_Board') or die ("connect fail");
$quer ="select * from board order by number desc";
$result = $connect -> query($quer);
$total = mysqli_num_rows($result);
session_start();
if(isset($_SESSION['userid'])) {
?><p style='display:inline;float:right;'> <b style="color:blue;float:left;"><?php echo $_SESSION['userid'];?></b> 님 안녕하세요
<button onclick="location.href='./login_out/logout.php'"> 로그아웃</button></p>
<br/>
<?php
}
else {
?> <button style='float:right' onclick="location.href='./login_out/login.php'">로그인</button>
<br />
<?php
}
?>
<br>
<h2 align=center>게시판</h2>
<table align = center>
<thead align = "center">
<tr>
<td width = "50" align="center">번호</td>
<td width = "500" align = "center">제목</td>
<td width = "100" align = "center">작성자</td>
<td width = "200" align = "center">날짜</td>
<td width = "50" align = "center">조회수</td>
</tr>
</thead>
<tbody>
<?php
while($rows = mysqli_fetch_assoc($result)){ //DB에 저장된 데이터 수 (열 기준)
if($total%2==0){
?> <tr class = "even">
<?php }
else{
?> <tr>
<?php } ?>
<td width = "50" align = "center"><?php echo $total?></td>
<td width = "500" align = "center">
<a href = "./post/view.php?number=<?php echo $rows['number']?>">
<?php echo $rows['title']?></td>
<td width = "100" align = "center"><?php echo $rows['id']?></td>
<td width = "200" align = "center"><?php echo $rows['date']?></td>
<td width = "50" align = "center"><?php echo $rows['hit']?></td>
</tr>
<?php
$total--;
}
?>
</tbody>
</table>
<div class = text>
<button style="background-color:#008CBA; border:none;color:white;padding:15px 32px;" onClick="location.href='./post/write.php'">글쓰기</button>
</div>
</body>
</html>