테스트 사이트 - 개발 중인 베타 버전입니다

db의 여불필드의 값을 체크박스로 구현 저장하기 채택완료

name1.jpg
① g5_write_name 테이블이 있습니다.
이곳 여분필드 wr_1 에는 각 레코드당 한명의 이름이 들어있습니다.
② 그리고 g5_write_staff 이름으로 새로운 테이블을 생성하였습니다.
이 게시판의 역할은 ①번 테이블(g5_write_name)의 각각 wr_1 에 있는 이름들을 체크박스 형식으로 write.skin.php 파일에 뿌려지게 됩니다.
그리고 체크박스에 체크한 이름들을 본 ② g5_write_staff 테이블의 여분필드 wr_4 에 저장을 하고자 합니다.
검색을 통해서 ①번 테이블의 명단을 가지고와 ②번 테이블 write.skin.php 에 뿌려지는 것까지는 성공을 했습니다.
②g5_write_staff/ write.skin.php
</span><span style='text-align: justify; color: #000000; line-height: 21px; font-family: "바탕"; font-size: 13px'>
<div style='margin: 0px; text-align: justify; color: #000000; line-height: 21px; text-indent: 0px; font-family: "바탕"; font-size: 13px'><span style='text-align: justify; color: #000000; line-height: 21px; font-family: "바탕"; font-size: 13px'><?php</span> </div>
<div style='margin: 0px; text-align: justify; color: #000000; line-height: 21px; text-indent: 0px; font-family: "바탕"; font-size: 13px'><span style='text-align: justify; color: #000000; line-height: 21px; font-family: "바탕"; font-size: 13px'>$query = "select wr_1 from g5_write_name";</span> </div>
<div style='margin: 0px; text-align: justify; color: #000000; line-height: 21px; text-indent: 0px; font-family: "바탕"; font-size: 13px'><span style='text-align: justify; color: #000000; line-height: 21px; font-family: "바탕"; font-size: 13px'>$result = mysql_query($query);</span><span style='text-align: justify; color: #000000; line-height: 21px; font-family: "바탕"; font-size: 13px'></span> </div>
<div style='margin: 0px; text-align: justify; color: #000000; line-height: 21px; text-indent: 0px; font-family: "바탕"; font-size: 13px'><span style='text-align: justify; color: #000000; line-height: 21px; font-family: "바탕"; font-size: 13px'>while($fetch = mysql_fetch_array($result)) {</span><span style='text-align: justify; color: #000000; line-height: 21px; font-family: "바탕"; font-size: 13px'></span> </div>
<div style='margin: 0px; text-align: justify; color: #000000; line-height: 21px; text-indent: 0px; font-family: "바탕"; font-size: 13px'><span style='text-align: justify; color: #000000; line-height: 21px; font-family: "바탕"; font-size: 13px'>$wr_name = $fetch[wr_1];</span> </div>
<div style='margin: 0px; text-align: justify; color: #000000; line-height: 21px; text-indent: 0px; font-family: "바탕"; font-size: 13px'><span style='text-align: justify; color: #000000; line-height: 21px; font-family: "바탕"; font-size: 13px'>?></span><span style='text-align: justify; color: #000000; line-height: 21px; font-family: "바탕"; font-size: 13px'></span> </div>
<div style='margin: 0px; text-align: justify; color: #000000; line-height: 21px; text-indent: 0px; font-family: "바탕"; font-size: 13px'><span style='text-align: justify; color: #000000; line-height: 21px; font-family: "바탕"; font-size: 13px'><input type="checkbox" name="wr_4[]" value="<?php echo $wr_name; ?>"><?php echo $wr_name; ?></span><span style='text-align: justify; color: #000000; line-height: 21px; font-family: "바탕"; font-size: 13px'></span> </div>
<div style='margin: 0px; text-align: justify; color: #000000; line-height: 21px; text-indent: 0px; font-family: "바탕"; font-size: 13px'><span style='text-align: justify; color: #000000; line-height: 21px; font-family: "바탕"; font-size: 13px'><? } ?></span> </div>
<div style='margin: 0px; text-align: justify; color: #000000; line-height: 21px; text-indent: 0px; font-family: "바탕"; font-size: 13px'></div></span></div>
<div style='margin: 0px; text-align: justify; color: #000000; line-height: 21px; text-indent: 0px; font-family: "바탕"; font-size: 13px'></div>
<div style='margin: 0px; text-align: justify; color: #000000; line-height: 21px; text-indent: 0px; font-family: "바탕"; font-size: 13px'></div>
 
 
그런데 이제 여분필드 wr_4 에 어떻게 저장을 해야 할지 도무지 모르겠습니다.
write_update.skin.php를 이용을 해야 하는 건가요?
어설픈 검색실력으로 다시 검색을 해보았습니다.
</div>
<div style='margin: 0px; text-align: justify; color: #000000; line-height: 21px; text-indent: 0px; font-family: "바탕"; font-size: 13px'><?php</div>
<div style='margin: 0px; text-align: justify; color: #000000; line-height: 21px; text-indent: 0px; font-family: "바탕"; font-size: 13px'><span style='text-align: justify; color: #000000; line-height: 21px; font-family: "바탕"; font-size: 13px'>foreach($_REQUEST['wr_4'] as $checkbox) { </span></div>
<div style='margin: 0px; text-align: justify; color: #000000; line-height: 21px; text-indent: 0px; font-family: "바탕"; font-size: 13px'><span style='text-align: justify; color: #000000; line-height: 21px; font-family: "바탕"; font-size: 13px'>$wr_4 = htmlspecialchars($checkbox);</span> </div>
<div style='margin: 0px; text-align: justify; color: #000000; line-height: 21px; text-indent: 0px; font-family: "바탕"; font-size: 13px'><span style='text-align: justify; color: #000000; line-height: 21px; font-family: "바탕"; font-size: 13px'>echo $wr_4;</span> </div>
<div style='margin: 0px; text-align: justify; color: #000000; line-height: 21px; text-indent: 0px; font-family: "바탕"; font-size: 13px'><span style='text-align: justify; color: #000000; line-height: 21px; font-family: "바탕"; font-size: 13px'>}</span> </div>
<div style='margin: 0px; text-align: justify; color: #000000; line-height: 21px; text-indent: 0px; font-family: "바탕"; font-size: 13px'></div>
<div style='margin: 0px; text-align: justify; color: #000000; line-height: 21px; text-indent: 0px; font-family: "바탕"; font-size: 13px'>?></div>
<div style='margin: 0px; text-align: justify; color: #000000; line-height: 21px; text-indent: 0px; font-family: "바탕"; font-size: 13px'>
 위의 내용이 있는데 foreach문으로 반복해서 배열에 저장된 값을 차례데로 뿌려주기는 하는데 이걸 어떻게 응용을 해야 할지 모르겠습니다..
가르침을 주십시오.. ㅠㅠ
댓글을 작성하려면 로그인이 필요합니다.

답변 1개

인내심을 가지고 검색을 통해 해결했습니다..

역시 이곳 냑질문에 모든 답이 있네요..ㅎㅎ

write_update.head.skin.php를 생성후..

$wr_4 = implode(",", $_POST['wr_4']);

위 코드 한줄로 해결이 되네요.. ^^;

감사합니다..

그리고 write_update.head.skin.php 를 이용하면 update 쿼리문이 필요없다는 것도 처음 알았습니다..^^;;

 

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인

전체 질문 목록

🐛 버그신고