Toggle navigation
Toggle navigation
This project
Loading...
Sign in
최시원
/
Singer-Composer
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
choi
2021-11-18 22:07:01 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
0c63c788e474ae579beae6966fe1b33cea7af23f
0c63c788
1 parent
27224428
add board page function
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
6 deletions
router/board/index.js
views/list.ejs
router/board/index.js
View file @
0c63c78
const
{
WSAECONNRESET
}
=
require
(
'constants'
);
const
e
=
require
(
'express'
);
var
express
=
require
(
'express'
);
const
{
connect
}
=
require
(
'http2'
);
...
...
@@ -14,18 +15,20 @@ router.get('/list/:page', function(req, res, next) {
else
{
var
page
=
req
.
params
.
page
;
var
sql
=
"select idx, name, title, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, "
+
"date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate from board"
;
"date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate
,hit
from board"
;
board
.
query
(
sql
,
function
(
err
,
rows
)
{
if
(
err
)
console
.
error
(
"err : "
+
err
);
var
id
=
req
.
user
.
ID
;
var
nickname
=
req
.
user
.
nickname
;
console
.
log
(
req
.
user
.
ID
+
'('
+
nickname
+
') 유저가 게시판을 보고있습니다.'
)
res
.
render
(
'list.ejs'
,
{
'ID'
:
id
,
'nickname'
:
nickname
,
title
:
'게시판 리스트'
,
rows
:
rows
})
res
.
render
(
'list.ejs'
,
{
'ID'
:
id
,
'nickname'
:
nickname
,
title
:
'게시판 리스트'
,
rows
:
rows
,
page
:
page
,
length
:
rows
.
length
-
1
,
page_num
:
10
,
pass
:
true
})
console
.
log
(
rows
.
length
-
1
)
})
}
});
router
.
get
(
'/list'
,
function
(
req
,
res
,
next
){
var
id
=
req
.
user
;
if
(
!
id
)
res
.
sendFile
(
path
.
join
(
__dirname
,
"../../public/login.html"
))
...
...
views/list.ejs
View file @
0c63c78
...
...
@@ -45,9 +45,11 @@
<td>
등록일
</td>
</tr>
<
%
for(var i=0; i
<rows
.
length
;
i
++)
{
var
data =
rows[i];
for(var i = (page * page_num) - page_num; i
<
(page * page_num); i++) {
if(i > length){
i++;
}else{
var data = rows[i]
%>
<tr>
<td>
<
%=data.idx%>
</td>
...
...
@@ -57,7 +59,20 @@
<td>
<
%=data.modidate%>
</td>
<td>
<
%=data.regdate%>
</td>
</tr>
<
%}%>
<
% }
}
%>
<tr>
<td
colspan=
"6"
>
<
%
for(var j = 0; j
< rows
.
length
/
page_num
;
j
++){
%
>
[
<a
href=
"/board/page/<%= j + 1 %>"
>
<
%= j + 1 %>
</a>
]
<
%
}
%>
</td>
</tr>
</table>
</div>
<!-- Footer-->
...
...
Please
register
or
login
to post a comment