choi

View latest bulletin first

...@@ -8,15 +8,13 @@ var path = require('path') // 상대경로 ...@@ -8,15 +8,13 @@ var path = require('path') // 상대경로
8 var mysql_odbc = require('../../db/db_board')(); 8 var mysql_odbc = require('../../db/db_board')();
9 var board = mysql_odbc.init(); 9 var board = mysql_odbc.init();
10 10
11 -
12 router.get('/list/:page', function(req, res, next) { 11 router.get('/list/:page', function(req, res, next) {
13 var id = req.user; 12 var id = req.user;
14 if(!id) res.redirect('/board/list/1') 13 if(!id) res.redirect('/board/list/1')
15 else{ 14 else{
16 var page = req.params.page; 15 var page = req.params.page;
17 var sql = "select idx, name, title, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, " + 16 var sql = "select idx, name, title, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, " +
18 - "date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate, hit from board"; 17 + "date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate, hit from board order by idx desc";
19 -
20 board.query(sql, function(err,rows) { 18 board.query(sql, function(err,rows) {
21 if (err) console.error("err : " + err); 19 if (err) console.error("err : " + err);
22 var id = req.user.ID; 20 var id = req.user.ID;
...@@ -45,11 +43,13 @@ router.get('/write', function(req,res,next){ ...@@ -45,11 +43,13 @@ router.get('/write', function(req,res,next){
45 }) 43 })
46 44
47 router.post('/write', function(req,res,next){ 45 router.post('/write', function(req,res,next){
48 - var name = req.body.name 46 + var id = req.user.ID
47 + var nickname = req.user.nickname
48 + //var name = req.body.name
49 var title = req.body.title 49 var title = req.body.title
50 var content = req.body.content 50 var content = req.body.content
51 - var passwd = req.body.passwd 51 + //var passwd = req.body.passwd
52 - var datas = [name,title,content,passwd] 52 + var datas = [ID, nickname,title,content]
53 53
54 var id; 54 var id;
55 var nickname; 55 var nickname;
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
44 <td>등록일</td> 44 <td>등록일</td>
45 </tr> 45 </tr>
46 <% 46 <%
47 - for(var i = (page * page_num) - page_num; i < (page * page_num); i++) { 47 + for(var i = (page * page_num)- page_num; i < (page * page_num); i++) {
48 if(i > length){ 48 if(i > length){
49 i++; 49 i++;
50 }else{ 50 }else{
...@@ -64,9 +64,10 @@ ...@@ -64,9 +64,10 @@
64 <tr> 64 <tr>
65 <td colspan="6"> 65 <td colspan="6">
66 <% 66 <%
67 - for(var j = 0; j < rows.length / page_num; j++){ 67 +
68 + for(var j = 0; j < rows.length/page_num ; j++){
68 %> 69 %>
69 - [<a href="/board/list/<%= j + 1 %>"><%= j + 1 %></a>] 70 + [<a href="/board/list/<%= j + 1 %>"><%= j+1 %></a>]
70 <% 71 <%
71 } 72 }
72 %> 73 %>
......