choi

View latest bulletin first

......@@ -8,15 +8,13 @@ var path = require('path') // 상대경로
var mysql_odbc = require('../../db/db_board')();
var board = mysql_odbc.init();
router.get('/list/:page', function(req, res, next) {
var id = req.user;
if(!id) res.redirect('/board/list/1')
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, hit from board";
"date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate, hit from board order by idx desc";
board.query(sql, function(err,rows) {
if (err) console.error("err : " + err);
var id = req.user.ID;
......@@ -45,11 +43,13 @@ router.get('/write', function(req,res,next){
})
router.post('/write', function(req,res,next){
var name = req.body.name
var id = req.user.ID
var nickname = req.user.nickname
//var name = req.body.name
var title = req.body.title
var content = req.body.content
var passwd = req.body.passwd
var datas = [name,title,content,passwd]
//var passwd = req.body.passwd
var datas = [ID, nickname,title,content]
var id;
var nickname;
......
......@@ -44,7 +44,7 @@
<td>등록일</td>
</tr>
<%
for(var i = (page * page_num) - page_num; i < (page * page_num); i++) {
for(var i = (page * page_num)- page_num; i < (page * page_num); i++) {
if(i > length){
i++;
}else{
......@@ -64,9 +64,10 @@
<tr>
<td colspan="6">
<%
for(var j = 0; j < rows.length / page_num; j++){
for(var j = 0; j < rows.length/page_num ; j++){
%>
[<a href="/board/list/<%= j + 1 %>"><%= j + 1 %></a>]
[<a href="/board/list/<%= j + 1 %>"><%= j+1 %></a>]
<%
}
%>
......