데이터베이스에 여러 개의 선택 값을 삽입하려고합니다.데이터베이스에 여러 개의 선택 값을 삽입하는 방법은 무엇입니까?
HTML
<select style="width:175px" id="first" multiple="true">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</div>
<div class="mid">
<button type="button" class='add'> > </button>
<button type="button" class='remove'> < </button>
<button type="button" class='add-all'> >>> </button>
<button type="button" class='remove-all'> <<< </button>
</div>
<div class="end">
<select style="width:175px" id="second" name="second[]" multiple="true">
</select>
</div>
<div style="clear:both;"></div>
자바 :
$('.add').click(function(){
$('#first option:selected').appendTo('#second');
});
$('.remove').click(function(){
$('#second option:selected').appendTo('#first');
});
$('.add-all').click(function(){
$('#first option').appendTo('#second');
});
$('.remove-all').click(function(){
$('#second option').appendTo('#first');
});
PHP (PHP 코드의 그것의 단지 작은 부분)
$formvars['second'] = $this->Sanitize($_POST['second']);
$insert_query = 'insert into 'comments'(second) values ("' . $this->SanitizeForSQL($formvars['second']) . '",)';
그 라이트 박스 만 단어 "배열"을 삽입 데이터 베이스. 어떤 생각?
코드 $ this-> SanitizeForSQL ($ formvars [ 'second'])이 배열을 반환하고이 방법으로 삽입 할 수 없기 때문입니다. 일괄 삽입 쿼리를 찾습니다. –