[php] 전체선택(체크박스)
페이지 정보
본문
----list.php-----------------
<?
include ("./db_conn.inc");
$qry="select * from board";
$result=mysql_query($qry);
?>
<html>
<head>
<title>admin</title>
<script>
function allcheck(form1)
{
for( var i=0; i<form1.elements.length; i++) {
var check = form1.elements[i];
check.checked = true;
}
return;
}
function uncheck(form1)
{
for( var i=0; i<form1.elements.length; i++) {
var check = form1.elements[i];
check.checked = false;
}
return;
}
</script>
</head>
<body>
<center>
<h4>글삭제</h4>
<form name=form1 action="del.php" method="post">
<table border="1" cellpadding="0" cellspacing="0" width="700">
<tr>
<td align="center">선택
</td>
<td align="center">작성일
</td>
<td align="center">글번호
</td>
<td align="center">이름
</td>
<td align="center">제목
</td>
<td align="center">조회수
</td>
</tr>
<?
while($row = mysql_fetch_object($result)) {
$key = $row->no;
echo "<tr>
<td align='center'><input type='checkbox' name='check[]' value='$key'>
</td>
<td align='center'>$row->date
</td>
<td align='center'>$row->no
</td>
<td align='center'>$row->name
</td>
<td align='center'>$row->title
</td>
<td align='right'>$row->see
</td>
</tr>";
}
mysql_free_result($result);
?>
</table>
<a href="javascript:allcheck(form1);">전체선택</a>
<a href="javascript:uncheck(form1);">선택해제</a><br>
<input type='submit' value='선택 삭제'>
</form>
</body>
</html>
</body>
</html>
-----del.php---------
<?
include("./db_conn.inc");
for($i=0;$i<count($check);$i++) {
$qry="delete from board where no='$check[$i]'";
mysql_query($qry);
}
mysql_close();
echo "<FONT face=돋움 color=silver>삭제되었습니다.</font>";
echo "<meta http-equiv='Refresh' content='0; URL=index.html'>";
?>
<?
include ("./db_conn.inc");
$qry="select * from board";
$result=mysql_query($qry);
?>
<html>
<head>
<title>admin</title>
<script>
function allcheck(form1)
{
for( var i=0; i<form1.elements.length; i++) {
var check = form1.elements[i];
check.checked = true;
}
return;
}
function uncheck(form1)
{
for( var i=0; i<form1.elements.length; i++) {
var check = form1.elements[i];
check.checked = false;
}
return;
}
</script>
</head>
<body>
<center>
<h4>글삭제</h4>
<form name=form1 action="del.php" method="post">
<table border="1" cellpadding="0" cellspacing="0" width="700">
<tr>
<td align="center">선택
</td>
<td align="center">작성일
</td>
<td align="center">글번호
</td>
<td align="center">이름
</td>
<td align="center">제목
</td>
<td align="center">조회수
</td>
</tr>
<?
while($row = mysql_fetch_object($result)) {
$key = $row->no;
echo "<tr>
<td align='center'><input type='checkbox' name='check[]' value='$key'>
</td>
<td align='center'>$row->date
</td>
<td align='center'>$row->no
</td>
<td align='center'>$row->name
</td>
<td align='center'>$row->title
</td>
<td align='right'>$row->see
</td>
</tr>";
}
mysql_free_result($result);
?>
</table>
<a href="javascript:allcheck(form1);">전체선택</a>
<a href="javascript:uncheck(form1);">선택해제</a><br>
<input type='submit' value='선택 삭제'>
</form>
</body>
</html>
</body>
</html>
-----del.php---------
<?
include("./db_conn.inc");
for($i=0;$i<count($check);$i++) {
$qry="delete from board where no='$check[$i]'";
mysql_query($qry);
}
mysql_close();
echo "<FONT face=돋움 color=silver>삭제되었습니다.</font>";
echo "<meta http-equiv='Refresh' content='0; URL=index.html'>";
?>
추천0
관련링크
댓글목록
등록된 댓글이 없습니다.