여분필드 분할입력 질문드립니다.
본문
write.skin.php 에서
$line_cnt = 7;
// 여분필드
$wr_4 = explode("|",$write["wr_4"]);
$wr_4_1 = $wr_4[0];
$wr_4_2 = $wr_4[1];
$wr_4_3 = $wr_4[2];
$wr_4_4 = $wr_4[3];
$wr_4_5 = $wr_4[4];
$wr_4_6 = $wr_4[5];
$wr_4_7 = $wr_4[6];
$wr_5 = explode("|",$write["wr_5"]);
$wr_5 = $wr_5[0];
$wr_5_2 = $wr_5[1];
$wr_5_3 = $wr_5[2];
$wr_5_4 = $wr_5[3];
$wr_5_5 = $wr_5[4];
$wr_5_6 = $wr_5[5];
$wr_5_7 = $wr_5[6];
$wr_6 = explode("|",$write["wr_6"]);
$wr_6_1 = $wr_6[0];
$wr_6_2 = $wr_6[1];
$wr_6_3 = $wr_6[2];
$wr_6_4 = $wr_6[3];
$wr_6_5 = $wr_6[4];
$wr_6_6 = $wr_6[5];
$wr_6_7 = $wr_6[6];
$wr_7 = explode("|",$write["wr_7"]);
$wr_7_1 = $wr_7[0];
$wr_7_2 = $wr_7[1];
$wr_7_3 = $wr_7[2];
$wr_7_4 = $wr_7[3];
$wr_7_5 = $wr_7[4];
$wr_7_6 = $wr_7[5];
$wr_7_7 = $wr_7[6];
$wr_8 = explode("|",$write["wr_8"]);
$wr_8_1 = $wr_8[0];
$wr_8_2 = $wr_8[1];
$wr_8_3 = $wr_8[2];
$wr_8_4 = $wr_8[3];
$wr_8_5 = $wr_8[4];
$wr_8_6 = $wr_8[5];
$wr_8_7 = $wr_8[6];
?>
//입력폼
<?php
for($i=1; $i<=$line_cnt; $i++){
?>
<tr>
<td><input type="text" name="wr_4_<?php echo $i?>" value="<?php echo $wr_4_[$i] ?>" id="wr_4_<?php echo $i?>" class="frm_input full_input " placeholder=""></td>
<td><input type="text" name="wr_5_<?php echo $i?>" value="<?php echo $wr_5_[$i] ?>" id="wr_5_<?php echo $i?>" class="frm_input full_input" placeholder=""></td>
<td><input type="text" name="wr_6_<?php echo $i?>" value="<?php echo $wr_6_[$i] ?>" id="wr_6_<?php echo $i?>" class="frm_input full_input num_only num_comma num_sum" placeholder=""></td>
<td><input type="text" name="wr_7_<?php echo $i?>" value="<?php echo $wr_7_[$i] ?>" id="wr_7_<?php echo $i?>" class="frm_input full_input num_only num_comma num_sum" placeholder=""></td>
<td><input type="text" name="wr_8_<?php echo $i?>" value="<?php echo $wr_8_[$i] ?>" id="wr_8_<?php echo $i?>" class="frm_input full_input num_only num_comma num_sum" placeholder=""></td>
</tr>
<?php } ?>
이렇게 작성을 해서 글쓰기를 했는데 데이터는 안들어가지네요.
write_update.skin.php를 한개 만들어서 올렸는데.
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
$wr_4 = "$wr_4_1|$wr_4_2|$wr_4_3|$wr_4_4|$wr_4_5|$wr_4_6|$wr_4_7|$wr_4_8|$wr_4_9|$wr_4_0|";
$wr_5 = "$wr_5_1|$wr_5_2|$wr_5_3|$wr_5_4|$wr_5_5|$wr_5_6|$wr_5_7|$wr_5_8|$wr_5_9|$wr_5_0|";
$wr_6 = "$wr_6_1|$wr_6_2|$wr_6_3|$wr_6_4|$wr_6_5|$wr_6_6|$wr_6_7|$wr_6_8|$wr_6_9|$wr_6_0|";
$wr_7 = "$wr_7_1|$wr_7_2|$wr_7_3|$wr_7_4|$wr_7_5|$wr_7_6|$wr_7_7|$wr_7_8|$wr_7_9|$wr_7_0|";
$wr_8 = "$wr_8_1|$wr_8_2|$wr_8_3|$wr_8_4|$wr_8_5|$wr_8_6|$wr_8_7|$wr_8_8|$wr_8_9|$wr_8_0|";
$sql1 = " update $write_table set wr_4 = '$wr_4',wr_5 = '$wr_5',wr_6 = '$wr_6',wr_7 = '$wr_7',wr_8 = '$wr_8' where wr_id = '$wr_id' ";
sql_query($sql1);
?>
이렇게 카피해서 올렸습니다.
제가 무식이라 여기 저기 찾아서 해본건데... ㅠㅠ
좀 도와주심 감사하겟습니다.
!-->!-->답변 4
입력폼에 여분 필드 분할은 아래거만 있어도 돼니 나머지 다 지우시고
$wr_4 = explode("|",$write["wr_4"]);
$wr_5 = explode("|",$write["wr_5"]);
$wr_6 = explode("|",$write["wr_6"]);
$wr_7 = explode("|",$write["wr_7"]);
$wr_8 = explode("|",$write["wr_8"]);
이거만 있어도 돼고요.
for 문은
<?php $line_cnt = 7;
for($i=0; $i<=$line_cnt; $i++){
?>
<tr>
<td><input type="text" name="wr_4_1[<?php echo $i?>]" value="<?php echo $wr_4[$i] ?>" id="wr_4_<?php echo $i?>" class="frm_input full_input " placeholder=""></td>
<td><input type="text" name="wr_5_1[<?php echo $i?>]" value="<?php echo $wr_5[$i] ?>" id="wr_5_<?php echo $i?>" class="frm_input full_input" placeholder=""></td>
<td><input type="text" name="wr_6_1[<?php echo $i?>]" value="<?php echo $wr_6[$i] ?>" id="wr_6_<?php echo $i?>" class="frm_input full_input num_only num_comma num_sum" placeholder=""></td>
<td><input type="text" name="wr_7_1[<?php echo $i?>]" value="<?php echo $wr_7[$i] ?>" id="wr_7_<?php echo $i?>" class="frm_input full_input num_only num_comma num_sum" placeholder=""></td>
<td><input type="text" name="wr_8_1[<?php echo $i?>]" value="<?php echo $wr_8[$i] ?>" id="wr_8_<?php echo $i?>" class="frm_input full_input num_only num_comma num_sum" placeholder=""></td>
</tr>
<?php } ?>
초기 값 0으로 바꾸시고 name과 value값 서로 바뀌었으니 수정하구요.
write.update.skin 은
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
$wr_4 = implode("|",$wr_4_1);
$wr_5 = implode("|",$wr_5_1);
$wr_6 = implode("|",$wr_6_1);
$wr_7 = implode("|",$wr_7_1);
$wr_8 = implode("|",$wr_8_1);
$sql1 = " update $write_table set wr_4 = '$wr_4',wr_5 = '$wr_5',wr_6 = '$wr_6',wr_7 = '$wr_7',wr_8 = '$wr_8' where wr_id = '$wr_id' ";
sql_query($sql1);
이렇게 해보세요.
!-->!-->!-->
어..저는 | 이거말고 , 콤마로 넣어서
wr_8 = "가,나,다,라";
explode(",",$write["wr_8"]);
빼서 써본 경험이 있습니다.
만약에 insert가 안된다면 컬럼의 varchar(255) 값을 넘어선게 아닌지 확인이 필요해보이며, 데이터 타입을 text로 바꿔서 넣어보시는 방법도 있을 것 같습니다.
explode를 이용해서 빼서 쓰시면 되고, 입력부분에서
$wr_4 = "$wr_4_1|$wr_4_2|$wr_4_3|$wr_4_4|$wr_4_5|$wr_4_6|$wr_4_7|$wr_4_8|$wr_4_9|$wr_4_0|";
$wr_4 = "$wr_4_1|$wr_4_2|
변수랑 문자열 합치는건
|가 아니라 ."|". 가 맞습니다.
답변을 작성하시기 전에 로그인 해주세요.