배열을 사용해서 여분필드 한 개로 연락처 입력란 3등분하기 오류 질문입니다.
본문
위 강좌입니다.
먼저 write.skin.php에 아래 구문을 삽입했습니다.
<div style="float:left;">
<div style="display:inline-block; margin-top:5px;"><span>연락받으실 전화번호</span>
<div style="margin-top:5px;">
<?php $hp = explode("-",$write['wr_2']); //연락처?>
<input type="text" name="hp[0]" value="<?php echo $hp[0] ?>" class="frm_input" size="8" maxlength="4" required> - <input type="text" name="hp[1]" value="<?php echo $hp[1] ?>" class="frm_input" size="10" maxlength="4" required> - <input type="text" name="hp[2]" value="<?php echo $hp[2] ?>" class="frm_input required" size="10" maxlength="4" required>
</div>
</div>
<div style="display:inline-block; margin:5px 0 0 30px;"><span>FAX번호</span>
<div style="margin-top:5px;">
<?php $hp = explode("-",$write['wr_3']); //연락처?>
<input type="text" name="hp[0]" value="<?php echo $hp[0] ?>" class="frm_input" size="8" maxlength="4"> - <input type="text" name="hp[1]" value="<?php echo $hp[1] ?>" class="frm_input" size="10" maxlength="4"> - <input type="text" name="hp[2]" value="<?php echo $hp[2] ?>" class="frm_input" size="10" maxlength="4">
</div>
</div>
</div>
write_update.skin.php에 다음 구문을 삽입했습니다.
// 연락받으실 전화번호
$wr_2 = "$hp[0]-$hp[1]-$hp[2]";
sql_query(" update $write_table set wr_2 = '$wr_2' where wr_id = '$wr_id' ");
// FAX번호
$wr_3 = "$hp[0]-$hp[1]-$hp[2]";
sql_query(" update $write_table set wr_3 = '$wr_3' where wr_id = '$wr_id' ");
정상적으로 동작합니다. 그러나
FAX번호를 지우면 연락받으실 전화번호까지 지워집니다.
어떻게 고쳐야 정상적으로 동작하죠?
답변 1
둘 다 hp로 사용하면 안 되겠죠. 팩스는 이렇게 하세요.
$wr_3 = "$fax[0]-$fax[1]-$fax[2]";
write.skin.php 파일에서도 팩스 입력 부분에서 hp로 되어 있는 것을 전부 fax로 변경.