묻고답하기
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
게시물 일괄수정에 대하여
2004.04.08 13:58
게시물 여러개를 한화면에 불러오고 나서 일괄적으로 수정할 수 있는 방법에 대한 소스가 있을 까요?
1.
<?
$today = getdate();
$b_mon = $today['mon']+1;
$b_day = $today['mday'];
$b_year = $today['year'];
$sql_search = " where (1) ";
if ($stext) {
$sql_search .= " and ( ";
switch ($sselect) {
case "ban_id" :
case "ban_name" :
$sql_search .= " ($sselect = '$stext') ";
break;
default :
$sql_search .= " ($sselect like '%$stext%') ";
break;
}
$sql_search .= " ) ";
}
$sql_common = " from 2004_wb ";
$sql_common .= $sql_search;
if (!$sort1) $sort1 = "ban_id";
if (!$sort2) $sort2 = "desc";
if (!$sno && !$stext) { $ssno = " and mon_sel = '$b_mon' "; }
else if (!$sno && $stext) { $ssno = ""; }
else if ($sno && $stext) { $ssno = " and mon_sel = $sno "; }
else { $ssno = " and mon_sel = $sno "; }
$sql = " select *
$sql_common $ssno
order by $sort1 $sort2 ";
$result = mysql_query($sql);
?>
<table cellpadding=4 cellspacing=1 width=100% class=tablebg>
<tr class=tdsc>
<td>
<p align="center">순서</p>
</td>
<td>
<p align="center"><?=subject_sort_link('ban_id'+ '+ ')?>무슨반</a></p>
</td>
<td>
<p align="center"><?=subject_sort_link('ban_name')?>이름</a></p>
</td>
<td>
<p align="center"><?=subject_sort_link('mb_id')?>부모id</a></p>
</td>
<td >
<p align="center"><?=subject_sort_link('mon_sel')?>월</a></p>
</td>
</tr>
</form>
<form name=frmitemlistupdate method=post action="./?doc=wonbi_list_update.php" autocomplete='off'>
<input type=hidden name=wr_num value="<? echo $row[wr_num] ?>">
<input type=hidden name=search value="<? echo $search ?>">
<input type=hidden name=page value="<? echo $page ?>">
<input type=hidden name=sort1 value="<? echo $sort1 ?>">
<input type=hidden name=sort2 value="<? echo $sort2 ?>">
<?
$p= 0;
for ($i=0; $row=mysql_fetch_array($result); $i++) {
$p++;
echo "
<tr $mouseover>
<td align=center>
<input type='hidden' name='wr_num[$i]' value='$row[wr_num]'>
$p</td>
<td><input type='text' name='ban_id[$i]' value='$row[ban_id]' size=7 class=text></td>
<td><input type='text' name='ban_name[$i]' value='$row[ban_name]' class=text size=5 style='text-align:right;'></td>
<td><input type='text' name='mb_id[$i]' value='$row[mb_id]' class=text size=5 style='+ 'text-align:right;'></td>
<td><input type='text' name='mon_sel[$i]' value='$row[mon_sel]' class=text size=2 style='text-align:right;'></td>
</tr>";
}
if ($i == 0)
echo "<tr><td colspan=20 align=center height=100 bgcolor=#FFFFFF><span class=point>자료가 한건도 없습니다.</span></td></tr>";
?>
</table>
<table width=100%>
<tr bgcolor=#ffffff>
<td width=50%><input type=submit value=' 일괄 수정 ' class=button></td>
<td width=50% align=right>
</td>
</tr>
</table>
</form>
2. 업데이트화일
<?
for ($i=0; $i<count($row[wr_num]); $i++) {
$sql = "update 2004_wb
set
ban_id = '$ban_id[$i]',
ban_name = '$ban_name[$i]',
mb_id = '$mb_id[$i]',
mon_sel = '$mon_sel[$i]'
where wr_num = '$wr_num[$i]' ";
mysql_query($sql);
}
?>
이런식으로 하는데 업데이트가 안되네요
아시는분은 좀 리플좀 주세요..
감사합니다.
1.
<?
$today = getdate();
$b_mon = $today['mon']+1;
$b_day = $today['mday'];
$b_year = $today['year'];
$sql_search = " where (1) ";
if ($stext) {
$sql_search .= " and ( ";
switch ($sselect) {
case "ban_id" :
case "ban_name" :
$sql_search .= " ($sselect = '$stext') ";
break;
default :
$sql_search .= " ($sselect like '%$stext%') ";
break;
}
$sql_search .= " ) ";
}
$sql_common = " from 2004_wb ";
$sql_common .= $sql_search;
if (!$sort1) $sort1 = "ban_id";
if (!$sort2) $sort2 = "desc";
if (!$sno && !$stext) { $ssno = " and mon_sel = '$b_mon' "; }
else if (!$sno && $stext) { $ssno = ""; }
else if ($sno && $stext) { $ssno = " and mon_sel = $sno "; }
else { $ssno = " and mon_sel = $sno "; }
$sql = " select *
$sql_common $ssno
order by $sort1 $sort2 ";
$result = mysql_query($sql);
?>
<table cellpadding=4 cellspacing=1 width=100% class=tablebg>
<tr class=tdsc>
<td>
<p align="center">순서</p>
</td>
<td>
<p align="center"><?=subject_sort_link('ban_id'+ '+ ')?>무슨반</a></p>
</td>
<td>
<p align="center"><?=subject_sort_link('ban_name')?>이름</a></p>
</td>
<td>
<p align="center"><?=subject_sort_link('mb_id')?>부모id</a></p>
</td>
<td >
<p align="center"><?=subject_sort_link('mon_sel')?>월</a></p>
</td>
</tr>
</form>
<form name=frmitemlistupdate method=post action="./?doc=wonbi_list_update.php" autocomplete='off'>
<input type=hidden name=wr_num value="<? echo $row[wr_num] ?>">
<input type=hidden name=search value="<? echo $search ?>">
<input type=hidden name=page value="<? echo $page ?>">
<input type=hidden name=sort1 value="<? echo $sort1 ?>">
<input type=hidden name=sort2 value="<? echo $sort2 ?>">
<?
$p= 0;
for ($i=0; $row=mysql_fetch_array($result); $i++) {
$p++;
echo "
<tr $mouseover>
<td align=center>
<input type='hidden' name='wr_num[$i]' value='$row[wr_num]'>
$p</td>
<td><input type='text' name='ban_id[$i]' value='$row[ban_id]' size=7 class=text></td>
<td><input type='text' name='ban_name[$i]' value='$row[ban_name]' class=text size=5 style='text-align:right;'></td>
<td><input type='text' name='mb_id[$i]' value='$row[mb_id]' class=text size=5 style='+ 'text-align:right;'></td>
<td><input type='text' name='mon_sel[$i]' value='$row[mon_sel]' class=text size=2 style='text-align:right;'></td>
</tr>";
}
if ($i == 0)
echo "<tr><td colspan=20 align=center height=100 bgcolor=#FFFFFF><span class=point>자료가 한건도 없습니다.</span></td></tr>";
?>
</table>
<table width=100%>
<tr bgcolor=#ffffff>
<td width=50%><input type=submit value=' 일괄 수정 ' class=button></td>
<td width=50% align=right>
</td>
</tr>
</table>
</form>
2. 업데이트화일
<?
for ($i=0; $i<count($row[wr_num]); $i++) {
$sql = "update 2004_wb
set
ban_id = '$ban_id[$i]',
ban_name = '$ban_name[$i]',
mb_id = '$mb_id[$i]',
mon_sel = '$mon_sel[$i]'
where wr_num = '$wr_num[$i]' ";
mysql_query($sql);
}
?>
이런식으로 하는데 업데이트가 안되네요
아시는분은 좀 리플좀 주세요..
감사합니다.