체크박스 수정시 체크 풀림
본문
write.skin.php
이렇게 했는데 체크박스 디비가 잘 저장되고 잘 나오는데 수정하려고 하면 체크가 유지가 안되는데 도와주세요ㅠㅠ !-->!-->!-->
해시태그
<?php
$wr_13_arr = isset($_POST['wr_13']) ? $_POST['wr_13'] : array();
$wr_13_str = explode('|', $row['wr_13_arr']);
?>
<input type="checkbox" name="wr_13[]" value="#보기1" <?php if(in_array("#보기1", $wr_13_arr)) echo "checked="; ?>><label>#보기1</label>
<input type="checkbox" name="wr_13[]" value="#보기2" <?php if(in_array("#보기2", $wr_13_arr)) echo "checked"; ?>><label>#보기2</label>
<input type="checkbox" name="wr_13[]" value="#보기3" <?php if(in_array("#보기3", $wr_13_arr)) echo "checked"; ?>><label>#보기3</label>
<input type="checkbox" name="wr_13[]" value="#보기4" <?php if(in_array("#보기4", $wr_13_arr)) echo "checked"; ?>><label>#보기4</label>
<input type="checkbox" name="wr_13[]" value="#보기5" <?php if(in_array("#보기5", $wr_13_arr)) echo "checked"; ?>><label>#보기5</label>
write_update.php
$wr_13_arr = isset($_POST['wr_13']) ? $_POST['wr_13'] : array();
$wr_13_str = implode('|', $wr_13_arr);
$sql = " insert into $write_table
set wr_num = '$wr_num',
wr_reply = '$wr_reply',
wr_comment = 0,
ca_name = '$ca_name',
wr_option = '$wr_option',
wr_subject = '$wr_subject',
wr_content = '$wr_content',
wr_seo_title = '$wr_seo_title',
wr_link1 = '$wr_link1',
wr_link2 = '$wr_link2',
wr_link1_hit = 0,
wr_link2_hit = 0,
wr_hit = 0,
wr_good = 0,
wr_nogood = 0,
mb_id = '{$member['mb_id']}',
wr_password = '$wr_password',
wr_name = '$wr_name',
wr_email = '$wr_email',
wr_homepage = '$wr_homepage',
wr_datetime = '".G5_TIME_YMDHIS."',
wr_last = '".G5_TIME_YMDHIS."',
wr_ip = '{$_SERVER['REMOTE_ADDR']}',
wr_1 = '$wr_1',
wr_2 = '$wr_2',
wr_3 = '$wr_3',
wr_4 = '$wr_4',
wr_5 = '$wr_5',
wr_6 = '$wr_6',
wr_7 = '$wr_7',
wr_8 = '$wr_8',
wr_9 = '$wr_9',
wr_10 = '$wr_10',
wr_11 = '$wr_11',
wr_12 = '$wr_12',
wr_13 = '$wr_13_str',
wr_14 = '$wr_14',
wr_15 = '$wr_15' ";
sql_query($sql);
$sql = " update {$write_table}
set ca_name = '{$ca_name}',
wr_option = '{$wr_option}',
wr_subject = '{$wr_subject}',
wr_content = '{$wr_content}',
wr_seo_title = '$wr_seo_title',
wr_link1 = '{$wr_link1}',
wr_link2 = '{$wr_link2}',
mb_id = '{$mb_id}',
wr_name = '{$wr_name}',
wr_email = '{$wr_email}',
wr_homepage = '{$wr_homepage}',
wr_1 = '{$wr_1}',
wr_2 = '{$wr_2}',
wr_3 = '{$wr_3}',
wr_4 = '{$wr_4}',
wr_5 = '{$wr_5}',
wr_6 = '{$wr_6}',
wr_7 = '{$wr_7}',
wr_8 = '{$wr_8}',
wr_9 = '{$wr_9}',
wr_10= '{$wr_10}',
wr_11= '{$wr_11}',
wr_12= '{$wr_12}',
wr_13= '{$wr_13_str}',
wr_14= '{$wr_14}',
wr_15= '{$wr_15}'
{$sql_ip}
{$sql_password}
where wr_id = '{$wr['wr_id']}' ";
sql_query($sql);
이렇게 했는데 체크박스 디비가 잘 저장되고 잘 나오는데 수정하려고 하면 체크가 유지가 안되는데 도와주세요ㅠㅠ !-->!-->!-->
답변 4
<?php
$wr_13_arr = explode('|', $wr_13);
?>
* write_update.skin.php
$wr_13_arr = isset($_POST['wr_13']) ? $_POST['wr_13'] : array();
$wr_13_str = implode(' ', $wr_13_arr);
$sql = " update {$write_table}
set wr_11= '{$wr_11}',
wr_12= '{$wr_12}',
wr_13= '{$wr_13_str}',
wr_14= '{$wr_14}',
wr_15= '{$wr_15}'
where wr_id = '{$wr['wr_id']}' ";
sql_query($sql);
if(in_array("#보기1", $wr_13_arr))
$wr_13_str 가 배열 아닌가요???
write_update.php
$wr_13_arr = isset($_POST['wr_13']) ? $_POST['wr_13'] : array();
$wr_13_str = implode(' ', $wr_13_arr);
$sql = " insert into $write_table
set wr_num = '$wr_num',
wr_reply = '$wr_reply',
wr_comment = 0,
ca_name = '$ca_name',
wr_option = '$wr_option',
wr_subject = '$wr_subject',
wr_content = '$wr_content',
wr_seo_title = '$wr_seo_title',
wr_link1 = '$wr_link1',
wr_link2 = '$wr_link2',
wr_link1_hit = 0,
wr_link2_hit = 0,
wr_hit = 0,
wr_good = 0,
wr_nogood = 0,
mb_id = '{$member['mb_id']}',
wr_password = '$wr_password',
wr_name = '$wr_name',
wr_email = '$wr_email',
wr_homepage = '$wr_homepage',
wr_datetime = '".G5_TIME_YMDHIS."',
wr_last = '".G5_TIME_YMDHIS."',
wr_ip = '{$_SERVER['REMOTE_ADDR']}',
wr_1 = '$wr_1',
wr_2 = '$wr_2',
wr_3 = '$wr_3',
wr_4 = '$wr_4',
wr_5 = '$wr_5',
wr_6 = '$wr_6',
wr_7 = '$wr_7',
wr_8 = '$wr_8',
wr_9 = '$wr_9',
wr_10 = '$wr_10',
wr_11 = '$wr_11',
wr_12 = '$wr_12',
wr_13 = '$wr_13_str',
wr_14 = '$wr_14',
wr_15 = '$wr_15' ";
sql_query($sql);
$sql = " update {$write_table}
set ca_name = '{$ca_name}',
wr_option = '{$wr_option}',
wr_subject = '{$wr_subject}',
wr_content = '{$wr_content}',
wr_seo_title = '$wr_seo_title',
wr_link1 = '{$wr_link1}',
wr_link2 = '{$wr_link2}',
mb_id = '{$mb_id}',
wr_name = '{$wr_name}',
wr_email = '{$wr_email}',
wr_homepage = '{$wr_homepage}',
wr_1 = '{$wr_1}',
wr_2 = '{$wr_2}',
wr_3 = '{$wr_3}',
wr_4 = '{$wr_4}',
wr_5 = '{$wr_5}',
wr_6 = '{$wr_6}',
wr_7 = '{$wr_7}',
wr_8 = '{$wr_8}',
wr_9 = '{$wr_9}',
wr_10= '{$wr_10}',
wr_11= '{$wr_11}',
wr_12= '{$wr_12}',
wr_13= '{$wr_13_str}',
wr_14= '{$wr_14}',
wr_15= '{$wr_15}'
{$sql_ip}
{$sql_password}
where wr_id = '{$wr['wr_id']}' ";
sql_query($sql);
이렇게입니다.
!-->!-->
답변을 작성하시기 전에 로그인 해주세요.