如果我插入超过 1 个值,是否可以分离数据库?
Is that possible to seperate database if i insert more than 1 value?
如果我插入超过1个值,我想将数据库分成两个。在图片中,您可以看到111111和111112在相同的角色中插入了“,”。我想将 111111 和 111112 作为每一行。我该怎么做?下面是我的数据库。
$seal_area = isset ($_GET['site'])? $_GET['site']:'';
$seal_qty = isset ($_GET['seal_qty'])? $_GET['seal_qty']:'';
$receive_by = isset ($_GET['stat'])? $_GET['stat']:'';
$seal_barcode = isset ($_GET['barcodeno'])? $_GET['barcodeno']:'';
$receive_id = isset ($_GET['secuid'])? $_GET['secuid']:'';
//$returnid = isset ($_GET['secuid'])? $_GET['secuid']:'';
$chk = isset ($_GET['chk'])? $_GET['chk']:'';
$admin_name = $_SESSION["loginname"];
if ($chk=='issue'){
$sql1 = "INSERT INTO access_request.tbl_sealcable (seal_barcode, seal_area, dt_issue, issue_admin, receive_by, receive_id) VALUES ('$seal_barcode','$seal_area',now(),'$admin_name','$receive_by','$receive_id')";
$result1 = mysqli_query($conn,$sql1);
}
/*else if ($chk=='rtn'){
$sql1 = "INSERT INTO access_request.tbl_sealcable (seal_barcode, seal_area, dt_issue, return_admin, return_id) VALUES ('$seal_barcode','$seal_area',now(),'$admin_name','$returnid')";
$result1 = mysqli_query($conn,$sql1);
}*/
flush();
mysqli_close($conn);
下面是javascript.
var barcodeno = document.translot.barcodeno.value;
if (barcodeno == ""){
alert("Please Insert Serial Numbers.")
return false;
}
$('#filter').html(''); // to clear selection
// lotid = $('#lotid').val().split('\n');
var barcodeno = $('#barcodeno').val().trim();
barcodeno = barcodeno.split('\n');
//checking duplicate barcodeno
let barcodeno_array = []
for(let i = 0;i < barcodeno.length; i++){
if(barcodeno_array.indexOf(barcodeno[i]) == -1){
barcodeno_array.push(barcodeno[i])
}
}
您可以使用 PHP explode() 函数,它用于在插入查询中循环数组后用逗号分隔字符串到数组的转换。
if ($chk=='issue'){
$barcodeArray = explode(",",$seal_barcode));
foreach($barcodeArray as $value){
$seal_barcode = $value;
$sql1 = "INSERT INTO access_request.tbl_sealcable (seal_barcode, seal_area, dt_issue, issue_admin, receive_by, receive_id) VALUES ('$seal_barcode','$seal_area',now(),'$admin_name','$receive_by','$receive_id')";
$result1 = mysqli_query($conn,$sql1);
}
}
如果我插入超过1个值,我想将数据库分成两个。
$seal_area = isset ($_GET['site'])? $_GET['site']:'';
$seal_qty = isset ($_GET['seal_qty'])? $_GET['seal_qty']:'';
$receive_by = isset ($_GET['stat'])? $_GET['stat']:'';
$seal_barcode = isset ($_GET['barcodeno'])? $_GET['barcodeno']:'';
$receive_id = isset ($_GET['secuid'])? $_GET['secuid']:'';
//$returnid = isset ($_GET['secuid'])? $_GET['secuid']:'';
$chk = isset ($_GET['chk'])? $_GET['chk']:'';
$admin_name = $_SESSION["loginname"];
if ($chk=='issue'){
$sql1 = "INSERT INTO access_request.tbl_sealcable (seal_barcode, seal_area, dt_issue, issue_admin, receive_by, receive_id) VALUES ('$seal_barcode','$seal_area',now(),'$admin_name','$receive_by','$receive_id')";
$result1 = mysqli_query($conn,$sql1);
}
/*else if ($chk=='rtn'){
$sql1 = "INSERT INTO access_request.tbl_sealcable (seal_barcode, seal_area, dt_issue, return_admin, return_id) VALUES ('$seal_barcode','$seal_area',now(),'$admin_name','$returnid')";
$result1 = mysqli_query($conn,$sql1);
}*/
flush();
mysqli_close($conn);
下面是javascript.
var barcodeno = document.translot.barcodeno.value;
if (barcodeno == ""){
alert("Please Insert Serial Numbers.")
return false;
}
$('#filter').html(''); // to clear selection
// lotid = $('#lotid').val().split('\n');
var barcodeno = $('#barcodeno').val().trim();
barcodeno = barcodeno.split('\n');
//checking duplicate barcodeno
let barcodeno_array = []
for(let i = 0;i < barcodeno.length; i++){
if(barcodeno_array.indexOf(barcodeno[i]) == -1){
barcodeno_array.push(barcodeno[i])
}
}
您可以使用 PHP explode() 函数,它用于在插入查询中循环数组后用逗号分隔字符串到数组的转换。
if ($chk=='issue'){
$barcodeArray = explode(",",$seal_barcode));
foreach($barcodeArray as $value){
$seal_barcode = $value;
$sql1 = "INSERT INTO access_request.tbl_sealcable (seal_barcode, seal_area, dt_issue, issue_admin, receive_by, receive_id) VALUES ('$seal_barcode','$seal_area',now(),'$admin_name','$receive_by','$receive_id')";
$result1 = mysqli_query($conn,$sql1);
}
}