Showing
2 changed files
with
24 additions
and
6 deletions
1 | +const { WSAECONNRESET } = require('constants'); | ||
1 | const e = require('express'); | 2 | const e = require('express'); |
2 | var express = require('express'); | 3 | var express = require('express'); |
3 | const { connect } = require('http2'); | 4 | const { connect } = require('http2'); |
... | @@ -14,18 +15,20 @@ router.get('/list/:page', function(req, res, next) { | ... | @@ -14,18 +15,20 @@ router.get('/list/:page', function(req, res, next) { |
14 | else{ | 15 | else{ |
15 | var page = req.params.page; | 16 | var page = req.params.page; |
16 | var sql = "select idx, name, title, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, " + | 17 | var sql = "select idx, name, title, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, " + |
17 | - "date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate from board"; | 18 | + "date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate,hit from board"; |
18 | 19 | ||
19 | board.query(sql, function(err,rows) { | 20 | board.query(sql, function(err,rows) { |
20 | if (err) console.error("err : " + err); | 21 | if (err) console.error("err : " + err); |
21 | var id = req.user.ID; | 22 | var id = req.user.ID; |
22 | var nickname = req.user.nickname; | 23 | var nickname = req.user.nickname; |
23 | console.log(req.user.ID+'('+nickname+') 유저가 게시판을 보고있습니다.') | 24 | console.log(req.user.ID+'('+nickname+') 유저가 게시판을 보고있습니다.') |
24 | - res.render('list.ejs', {'ID':id, 'nickname': nickname, title: '게시판 리스트', rows: rows}) | 25 | + res.render('list.ejs', {'ID':id, 'nickname': nickname, title: '게시판 리스트', rows: rows, page:page, length:rows.length-1,page_num:10,pass:true}) |
26 | + console.log(rows.length-1) | ||
25 | }) | 27 | }) |
26 | } | 28 | } |
27 | }); | 29 | }); |
28 | 30 | ||
31 | + | ||
29 | router.get('/list', function(req,res,next){ | 32 | router.get('/list', function(req,res,next){ |
30 | var id = req.user; | 33 | var id = req.user; |
31 | if(!id) res.sendFile(path.join(__dirname, "../../public/login.html")) | 34 | if(!id) res.sendFile(path.join(__dirname, "../../public/login.html")) | ... | ... |
... | @@ -45,9 +45,11 @@ | ... | @@ -45,9 +45,11 @@ |
45 | <td>등록일</td> | 45 | <td>등록일</td> |
46 | </tr> | 46 | </tr> |
47 | <% | 47 | <% |
48 | - for(var i=0; i<rows.length; i++) | 48 | + for(var i = (page * page_num) - page_num; i < (page * page_num); i++) { |
49 | - { | 49 | + if(i > length){ |
50 | - var data = rows[i]; | 50 | + i++; |
51 | + }else{ | ||
52 | + var data = rows[i] | ||
51 | %> | 53 | %> |
52 | <tr> | 54 | <tr> |
53 | <td><%=data.idx%></td> | 55 | <td><%=data.idx%></td> |
... | @@ -57,7 +59,20 @@ | ... | @@ -57,7 +59,20 @@ |
57 | <td><%=data.modidate%></td> | 59 | <td><%=data.modidate%></td> |
58 | <td><%=data.regdate%></td> | 60 | <td><%=data.regdate%></td> |
59 | </tr> | 61 | </tr> |
60 | - <%}%> | 62 | + <% } |
63 | + } | ||
64 | + %> | ||
65 | + <tr> | ||
66 | + <td colspan="6"> | ||
67 | + <% | ||
68 | + for(var j = 0; j < rows.length / page_num; j++){ | ||
69 | + %> | ||
70 | + [<a href="/board/page/<%= j + 1 %>"><%= j + 1 %></a>] | ||
71 | + <% | ||
72 | + } | ||
73 | + %> | ||
74 | + </td> | ||
75 | + </tr> | ||
61 | </table> | 76 | </table> |
62 | </div> | 77 | </div> |
63 | <!-- Footer--> | 78 | <!-- Footer--> | ... | ... |
-
Please register or login to post a comment