여분필드 입력 후 수정하면 값이 없어집니다.
본문
https://gnustudy.com/bbs/board.php?bo_table=skin_board&wr_id=10
해당 페이지를 참고해서 만들었습니다.
write.skin.php
<div class="write_div">
<label for="wr_5" class="sound_only">전문분야</label>
<?php
$wr5 = explode(",", $write['wr_5']);
?>
<input type="checkbox" name="wr5[0]" value="A" <?php echo ($wr5[0] == "A") ? "checked" : "";?>> A
<input type="checkbox" name="wr5[1]" value="B" <?php echo ($wr5[1] == "B") ? "checked" : "";?>> B
<input type="checkbox" name="wr5[2]" value="C" <?php echo ($wr5[2] == "C") ? "checked" : "";?>> C
</div>
write_update.skin.php
$wr_5 = "$wr5[0]|$wr5[1]|$wr5[2]";
sql_query(" update $write_table set wr_5 = '$wr_5' where wr_id = '$wr_id' ");
제가 뭘 놓치고 있는지 모르겠습니다ㅠ
!-->!-->답변 1
<div class="write_div">
<label for="wr_5" class="sound_only">전문분야</label>
<?php
$wr5 = explode("|", $write['wr_5']);
$options = array('A', 'B', 'C');
foreach ($options as $option) {
$checked = (in_array($option, $wr5)) ? 'checked' : '';
?>
<input type="checkbox" name="wr5[]" value="<?php echo $option; ?>" <?php echo $checked; ?>> <?php echo $option; ?>
<?php
}
?>
</div>
//배열정의로 인해서 받아서처리해보세요
답변을 작성하시기 전에 로그인 해주세요.