0
하나의 선택으로 데이터베이스에 두 개의 값을 삽입해야합니다.하나의 선택만으로 mysql에 두 개의 값을 삽입하려면 어떻게해야합니까?
내 양식 : 사용자가 양식을 제출하기 전에 더 많은 선택을 추가 할 수 있습니다
<form action="updateresult.php" method="post" name="edit">
<div class="row">
<div class="content">
<div class="pull-left">
<select name="eplayer_id[]" class="tripObject">
<option value="%">Select</option>
<?php
$lastteam = "";
do {
?>
<?php if ($lastteam != $row_datagoal['tteam'])
echo '<optgroup label="'.$row_datagoal['name'].'">';
echo '<option value="'.$row_datagoal['id'].','.$row_datagoal['tteam'].'">'.$row_datagoal['playerName'].'</option>';
if ($lastteam != $row_datagoal['tteam'])
echo '</optgroup>';
$lastteam = $row_datagoal['tteam'];
?>
<?php
} while ($row_datagoal = mysql_fetch_assoc($datagoal));
$rows = mysql_num_rows($datagoal);
if($rows > 0) {
mysql_data_seek($datagoal, 0);
$row_datagoal = mysql_fetch_assoc($datagoal);
}
?>
</select>
<input class="inputfieldres" name="ecount[]" type="text" value="" size="2" maxlength="2" />
<input type="hidden" name="ematch_id[]" value="<?php echo $row_dataresults['id']; ?>" />
</div>
</div>
</div>
<a href="#" id="Add">ADD MORE SELECT</a>
<input class="btnresults" type="submit" value="Save" />
<input type="hidden" name="MM_insert" value="form1" />
</form>
. 제출 난 후
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")){
$newteam = explode (",",$_POST['eplayer_id']);
for($j=0,$len=count($newteam[0]);$j<$len;$j++){
$insertSQL = sprintf("INSERT INTO f_matchevents (eplayer_id, eteam_id, ematch_id, ecount) VALUES (%s, %s, %s, %s)",
GetSQLValueString(trim($newteam[0] [$j]), "int"),
GetSQLValueString(trim($newteam[1] [$j]), "int"),
GetSQLValueString($_POST['ematch_id'] [$j], "int"),
GetSQLValueString($_POST['ecount'] [$j], "int"));
mysql_select_db($database_config, $config);
$Result1 = mysql_query($insertSQL, $config) or die(mysql_error());}
$insertGoTo = "player_list.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
:
$(document).ready(function(){
$("#Add").click(function(){
var obj = $("div.content").eq(0).clone(); //this will clone the html elements
obj.append('<div class="pull-left"><a href="#"onclick="removeDOM(this)"><img src="images/p6_delete.gif" width="14" height="14" alt="Remove" /></a></div>');
$("div.row").append(obj); //this will append to the existing elements
});
});
function removeDOM(thisObj){
$(thisObj).parent().parent().remove();
}
내가 다음 쿼리를 시도 내 DB 테이블에 데이터를 삽입하려면 :이 작업을 수행하기 위해 나는 형태로 항목을 복제합니다 다음 스크립트를 사용 다음 오류 메시지가 표시됩니다.
Warning: explode() expects parameter 2 to be string, array given in C:\xampp\htdocs\*****\updateresult.php on line 43
미리 도움을 주셔서 감사합니다.
감사합니다. charme ;-)와 유사합니다. – blips