본문 바로가기

Update4

[Python] 업데이트하기(input, format, rename) [생활코딩] 활용 - 수정 구현 pageId값 유무에 따라 update 버튼 출력 index.py #!/usr/local/bin/python3 print("content-type:text/html; charset=UTF-8\n") import cgi,os files = os.listdir('data') liststr = '' for item in files: liststr = liststr + '{name}'.format(name=item) form = cgi.FieldStorage() if 'id' in form: pageId = form["id"].value description = open('data/'+pageId).read() update_link = 'update'.format(pageid=p.. 2020. 8. 23.
[Nodejs-mysql] 테이블값 업데이트 하기 [생화코딩] 저자 수정 기능 구현 lib/template.js authorTable:function(authors){ var tag = ''; var i = 0; while(i < authors.length){ tag += ` ${authors[i].name} ${authors[i].profile} update delete `; i++; }; // update에 a태그 붙이고 이동 링크는 author/update?id=author의 id값 tag += ''; return tag; } lib/author.js var db = require('./db'); var template = require('./template.js'); var qs = require('querystring'); var url = r.. 2020. 8. 7.
[Nodejs-mysql] Select값 수정하기 [생활코딩] MySQL join을 이용해서 글수정 구현 수정페이지에 Select 넣고 선택되었던 option 출력하기 main.js if(pathname === '/update'){ db.query('SELECT*FROM topic', function(error, topics){ if(error){ throw error; } db.query('SELECT*FROM topic WHERE id=?', [queryData.id], function(error2, topic){ if(error2){ throw error2; } db.query('SELECT*FROM author', function(error3, authors){ // author값 받아서 authors에 담기 var list = template... 2020. 8. 7.
[Nodejs-mysql] 데이터 수정/삭제하기 [생활코딩] MySQL로 글 수정 기능 구현 [생활코딩] MySQL로 글 삭제 기능 구현 수정할 데이터 폼에 출력 if(pathname === '/update'){ db.query('SELECT*FROM topic', function(error, topics){ // topic 데이터 불러와 topics에 담음 if(error){ throw error; } // 예외처리 db.query('SELECT*FROM topic WHERE id=?', [queryData.id], function(error2, topic){ // topic의 특정 id값을 가져와 topic에 담음 // id값은 배열로 가져와 ?에 치환하며, 그 값은 queryData.id if(error2){ throw error2; } // 예.. 2020. 8. 6.
반응형