如何将09 MySQL Query转换为单个查询

时间:2017-12-13 11:28:57

标签: php mysql

如何将此查询转换为单个查询或建议我如何将它们插入到数据库中。如果有任何编码错误,请纠正我。

这是我的代码:

<?php
$dbcon = mysqli_connect("localhost", "root", "", "tec") or     die(mysqli_error($dbcon));
$saveweave = filter_input(INPUT_POST, 'saveweave');
if(isset($saveweave)){
$roll = mysqli_real_escape_string($dbcon, filter_input(INPUT_POST,'roll'));
$libtutfee = mysqli_real_escape_string($dbcon, filter_input(INPUT_POST,'libtutfee'));
$libsemno = mysqli_real_escape_string($dbcon, filter_input(INPUT_POST,'libsemno'));
$reference = mysqli_real_escape_string($dbcon, filter_input(INPUT_POST,'reference'));
$addedby=$_SESSION['mysesi'];
if($libsemno === '1'){
$res = ("INSERT into `waiver_tut` (roll_id, wt1, wt2, wt3, wt4, wt5, wt6, wt7, wt8, addedby, reference) VALUES ('$roll', '$libtutfee', '$libtutfee', '$libtutfee', '$libtutfee', '$libtutfee', '$libtutfee', '$libtutfee', '$libtutfee','$addedby', '$reference')");
}
if($libsemno === '2'){
$res = ("INSERT into `waiver_tut` (roll_id, wt1, wt2, wt3, wt4, wt5, wt6, wt7, wt8, addedby, reference) VALUES ('$roll', '0', '$libtutfee', '$libtutfee', '$libtutfee', '$libtutfee', '$libtutfee', '$libtutfee', '$libtutfee','$addedby', '$reference')");
}
if($libsemno === '3'){
$res = ("INSERT into `waiver_tut` (roll_id, wt1, wt2, wt3, wt4, wt5, wt6, wt7, wt8, addedby, reference) VALUES ('$roll', '0', '0', '$libtutfee', '$libtutfee', '$libtutfee', '$libtutfee', '$libtutfee', '$libtutfee','$addedby', '$reference')");
}
if($libsemno === '4'){
$res = ("INSERT into `waiver_tut` (roll_id, wt1, wt2, wt3, wt4, wt5, wt6, wt7, wt8, addedby, reference) VALUES ('$roll', '0', '0', '0', '$libtutfee', '$libtutfee', '$libtutfee', '$libtutfee', '$libtutfee','$addedby', '$reference')");
}
if($libsemno === '5'){
$res = ("INSERT into `waiver_tut` (roll_id, wt1, wt2, wt3, wt4, wt5, wt6, wt7, wt8, addedby, reference) VALUES ('$roll', '0', '0', '0', '0', '$libtutfee', '$libtutfee', '$libtutfee', '$libtutfee','$addedby', '$reference')");
 }
 if($libsemno === '6'){
$res = ("INSERT into `waiver_tut` (roll_id, wt1, wt2, wt3, wt4, wt5, wt6, wt7, wt8, addedby, reference) VALUES ('$roll', '0', '0', '0', '0', '0', '$libtutfee', '$libtutfee', '$libtutfee','$addedby', '$reference')");
}
if($libsemno === '7'){
$res = ("INSERT into `waiver_tut` (roll_id, wt1, wt2, wt3, wt4, wt5, wt6, wt7, wt8, addedby, reference) VALUES ('$roll', '0', '0', '0', '0', '0', '0', '$libtutfee', '$libtutfee','$addedby', '$reference')");
}
if($libsemno === '8'){
$res = ("INSERT into `waiver_tut` (roll_id, wt1, wt2, wt3, wt4, wt5, wt6, wt7, wt8, addedby, reference) VALUES ('$roll', '0', '0', '0', '0', '0', '0', '0', '$libtutfee','$addedby', '$reference')");
}
if($libsemno === '0'){
$res = ("INSERT into `waiver_tut` (roll_id, wt1, wt2, wt3, wt4, wt5, wt6, wt7, wt8, addedby, reference) VALUES ('$roll', '0', '0', '0', '0', '0', '0', '0', '0','$addedby', '$reference')");
}
if ($dbcon->query($res) === TRUE) {
do something

请帮助转换查询....

0 个答案:

没有答案