-
Notifications
You must be signed in to change notification settings - Fork 2
/
docs-search.php
148 lines (139 loc) · 5.88 KB
/
docs-search.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
147
148
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link
rel="preconnect"
href="https://fonts.gstatic.com"
crossorigin="crossorigin">
<link
href="https://fonts.googleapis.com/css2?family=Gugi&display=swap"
rel="stylesheet">
<script src="https://kit.fontawesome.com/7395e48b31.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="style.css">
<title>억새풀</title>
</head>
<body>
<?php include_once("header.html"); ?>
<section id="" class="section">
<div class="section_container">
<div>
<div class="doc_title">
<h1>자료실</h1>
<hr class="hr_darkgray">
</div>
<?php
//현재 페이지탐색
if(!isset($_COOKIE["docsPageCookie"])) {
setcookie("docsPageCookie","1",time()+(600),"/") ; //86400=1day
$currentPage = 1;
} else {
$currentPage = $_COOKIE["docsPageCookie"];
}
require_once "dbcon.php";
//전체 페이지수
$stmt = $conn -> prepare("SELECT COUNT(*) AS \"num\" FROM sell_info where deleteDate IS NULL");
$stmt -> execute();
$result = $stmt -> get_result();
$row = $result -> fetch_assoc();
$totalNum=$row['num'];
$totalPageNum = ceil($totalNum/20);
$stmt = $conn -> prepare("SELECT * FROM sell_info where deleteDate IS NULL ORDER BY upload DESC LIMIT ?,20");
$stmt -> bind_param("i",$page);
$page = ($currentPage-1)*20;
$stmt -> execute();
$result = $stmt -> get_result();
//---------------------상단검색
?>
<div class="search_box">
<div class="search_box_page">
<p>페이지 :
<?= $currentPage ?>/<?=$totalPageNum ?></p>
<p>총게시물 :
<?= $totalNum ?></p>
</div>
<div class="search_box_search">
<form
name="docsForm"
method="post"
action="docs-search-submit.php"
enctype="multipart/form-data">
<div class="flex">
<div class="input_row">
<input
type="text"
name="searchWord"
required="required"
class="input_text"
placeholder="제목 입력해 주세요">
</div>
<input type="submit" value="검색" class="btn_white" name="submit">
</div>
</form>
</div>
</div>
<?php
//--------------------------------------------게시물
$n=0;
if($result!=NULL){
while($row = $result -> fetch_assoc()){
$n++;
echo("
<div class=\"docs_box\" onclick=\"document.forms['docID".$row['id']."'].submit();\">
<form method=\"post\" action=\"docs-info.php\" enctype=\"multipart/form-data\" name=\"docID".$row['id']."\">
<h2>제목 : ".htmlspecialchars($row['title'])."</h2>
<h4>등록자 : ".htmlspecialchars($row['member_name'])."</h4>
<h3>가격 : ".htmlspecialchars($row['price'])."</h3>
<input type=\"hidden\" name=\"docId\" value=\"".htmlspecialchars($row['id'])."\" >
</form>
</div>
");
}
}else{
echo("<h2>검색결과가 없습니다</h2>");
}
$stmt->close();
$conn->close();
//--------------------------------------------페이지
$showingPage=4; //앞뒤로 보여지는 페이지 수
echo("<div class=\"section\">");
echo("<form method=\"post\" >");
echo("<table style=\" display:inline-block; text-align: center;\" > <tr>");
if (($currentPage-$showingPage)<=1){
for($i=1;$i<$currentPage;$i++){
echo("<td class=\"page_table\" onclick=\"refresh(".$i.")\">".$i."</td>");
}
}else{
echo("<td class=\"page_table\" onclick=\"refresh(".($currentPage-$showingPage-1).")\"> ... </td>");
for($i=$currentPage-$showingPage;$i<$currentPage;$i++){
echo("<td class=\"page_table\" onclick=\"refresh(".$i.")\">".$i."</td>");
}
}
echo("<td class=\"page_table_currentPage\">".$currentPage."</td>");
if(($currentPage+$showingPage)>=$totalPageNum){
for($i=$currentPage+1;$i<=$totalPageNum;$i++){
echo("<td class=\"page_table\" onclick=\"refresh(".$i.")\">".$i."</td>");
}
}else{
for($i=$currentPage+1;$i<=($currentPage+$showingPage);$i++){
echo("<td class=\"page_table\" onclick=\"refresh(".$i.")\">".$i."</td>");
}
echo("<td class=\"page_table\" onclick=\"refresh(".($currentPage+$showingPage+1).")\"> ... </td>");
}
echo("</tr> </table> </form> </div>");
?>
</div>
</section>
</div>
<?php include_once("footer.html"); ?>
<script>
function refresh(page) {
document.cookie = ("<?=" docsPageCookie "?> =" + page);
location.reload();
}
</script>
</body>
</html>