답변 2개 / 댓글 3개
채택된 답변
+20 포인트
다음 코드가 도움이 될지 모르겠습니다.
Copy
<?php
$chk = isset($_POST['chk']) ? $_POST['chk'] : null;
if (empty($chk) == false) {
$wr_1 = "'" . addslashes(implode(',', $chk)) . "'";
$sql = " INSERT INTO tablename (wr_1) VALUES ({$wr_1}); ";
echo $sql;
}
?>
<form method="post">
<ul>
<li><label><input type="checkbox" name="chk[]" value="chk-1"> chk-1</label></li>
<li><label><input type="checkbox" name="chk[]" value="chk-2"> chk-2</label></li>
<li><label><input type="checkbox" name="chk[]" value="chk-3"> chk-3</label></li>
<li><label><input type="checkbox" name="chk[]" value="chk-4"> chk-4</label></li>
<li><label><input type="checkbox" name="chk[]" value="chk-5"> chk-5</label></li>
<li><input type="submit"></li>
</ul>
</form>
답변을 작성하려면 로그인이 필요합니다.