체크박스 풀림 문의
본문
상품등록폼에 아래 체크박스 코드로 수정하고
<tr class="skill_radio" >
<th scope="row"><label for="it_maker">③ 지역</label></th>
<?php
$fax = explode(",",$it['it_maker']); // 품목
?>
<td>
<label><input type="checkbox" name="fax[0]" value="서울," <?php echo ($it['it_maker'] == '서울') ? "checked" : ""; ?><?php echo $fax[0] ?>> 서울</label>
<label><input type="checkbox" name="fax[1]" value="경기," <?php echo ($it['it_maker'] == '경기') ? "checked" : ""; ?><?php echo $fax[1] ?>> 경기</label>
<label><input type="checkbox" name="fax[2]" value="인천," <?php echo ($it['it_maker'] == '인천') ? "checked" : ""; ?><?php echo $fax[2] ?>> 인천</label>
<label><input type="checkbox" name="fax[3]" value="강원," <?php echo ($it['it_maker'] == '강원') ? "checked" : ""; ?><?php echo $fax[3] ?>> 강원</label>
<label><input type="checkbox" name="fax[4]" value="충북," <?php echo ($it['it_maker'] == '충북') ? "checked" : ""; ?><?php echo $fax[4] ?>> 충북</label>
<label><input type="checkbox" name="fax[5]" value="충남," <?php echo ($it['it_maker'] == '충남') ? "checked" : ""; ?><?php echo $fax[5] ?>> 충남</label>
<label><input type="checkbox" name="fax[6]" value="대전," <?php echo ($it['it_maker'] == '대전') ? "checked" : ""; ?><?php echo $fax[6] ?>> 대전</label>
<label><input type="checkbox" name="fax[7]" value="세종," <?php echo ($it['it_maker'] == '세종') ? "checked" : ""; ?><?php echo $fax[7] ?>> 세종</label>
<label><input type="checkbox" name="fax[8]" value="전북," <?php echo ($it['it_maker'] == '전북') ? "checked" : ""; ?><?php echo $fax[8] ?>> 전북</label>
<label><input type="checkbox" name="fax[9]" value="전남," <?php echo ($it['it_maker'] == '전남') ? "checked" : ""; ?><?php echo $fax[9] ?>> 전남</label>
<label><input type="checkbox" name="fax[10]" value="광주," <?php echo ($it['it_maker'] == '광주') ? "checked" : ""; ?><?php echo $fax[10] ?>> 광주</label>
<label><input type="checkbox" name="fax[11]" value="경북," <?php echo ($it['it_maker'] == '경북') ? "checked" : ""; ?><?php echo $fax[11] ?>> 경북</label>
<label><input type="checkbox" name="fax[12]" value="대구," <?php echo ($it['it_maker'] == '대구') ? "checked" : ""; ?><?php echo $fax[12] ?>> 대구</label>
<label><input type="checkbox" name="fax[13]" value="경남," <?php echo ($it['it_maker'] == '경남') ? "checked" : ""; ?><?php echo $fax[13] ?>> 경남</label>
<label><input type="checkbox" name="fax[14]" value="울산," <?php echo ($it['it_maker'] == '울산') ? "checked" : ""; ?><?php echo $fax[14] ?>> 울산</label>
<label><input type="checkbox" name="fax[15]" value="부산," <?php echo ($it['it_maker'] == '부산') ? "checked" : ""; ?><?php echo $fax[15] ?>> 부산</label>
<label><input type="checkbox" name="fax[16]" value="제주," <?php echo ($it['it_maker'] == '제주') ? "checked" : ""; ?><?php echo $fax[16] ?>> 제주</label>
<label><input type="checkbox" name="fax[17]" value="전국," <?php echo ($it['it_maker'] == '전국') ? "checked" : ""; ?><?php echo $fax[17] ?>> 전국</label>
</td>
</tr>
itemfomupdate부분에 아래 소스를 추가해서
$it_maker = "$fax[0]$fax[1]$fax[2]$fax[3]$fax[4]$fax[5]$fax[6]$fax[7]$fax[8]$fax[9]$fax[10]$fax[11]$fax[12]$fax[13]$fax[14]$fax[15]$fax[16]$fax[17]";
sql_query(" update {$g5['member_table']} set it_maker = '$it_maker' where mb_id = '$mb_id' ");
다중 체크박스 구현을 했는데요
값은 넘어오는데 수정시 체크박스가 풀리네여...
노란색친부분이 이상한거 같은데 어케 해야할까요
영카트 상품 등록폼이니다ㅣ!!
답변 2
echo ($it['it_maker'] == '서울') ? "checked" : "";
대신
echo (in_array('서울', $fax ) ) ? "checked" : "";
$it_maker = "$fax[0]$fax[1]$fax[2]$fax[3]$fax[4]$fax[5]$fax[6]$fax[7]$fax[8]$fax[9]$fax[10]$fax[11]$fax[12]$fax[13]$fax[14]$fax[15]$fax[16]$fax[17]";
대신
$it_maker = implode(',', $fax);
이렇게 바꿔 보세요.
$it_maker 값을 만드실때 $fax 변수를 일일이 하시다 보니까 중간에 , 부분이 빠져서 그렇습니다.
$it_maker = "$fax[0],$fax[1]";
이렇게 사이에 , 구분자를 넣어주셔야 합니다.