<?php
include "../../settings.php";
include "$basepath/includes/conn.php";
/*$receiptnum='';*/
$submittedby='';
$statementno='';
$amount='';
$accno='';
$dateofpayment='';
if(isset($_POST['submit'])) { /*$receiptnum=$_POST['receiptnum']; */
$statementno=$_POST['statementno']; $amount=$_POST['amount'];
$accno=$_REQUEST['accountnum']; $submittedby=$_POST['submitby'];
$dateofpayment=$_REQUEST['dateofpayment']; }
/*$query= "CALL newreceipt('$reciptnum','$statementno','$amount',@doj1,'$accno','$submitedby')";*/
$query="INSERT into statement(statementno) VALUES('".$statementno."')";
$query.="INSERT into
receipt(statementno,accountnum,dateofpayment,amount,submittedby)
VALUES('".$statementno."','".$accno."','".$dateofpayment."','".$amount."','".$submittedby."')";
$result=mysqli_multi_query($con,$query); {
if($result) {
die ("An unexpected error , Please try again!");
} else {
header('Location: receipt.php');
}
}
?>
问问题
3086 次
1 回答
1
根据官方文档,您有两种方法可以做到这一点。由于您没有使用面向对象的方式,因此我将几乎复制粘贴程序方式的示例(如我所说,来自文档):
// Your queries
$query="INSERT into statement(statementno) VALUES('".$statementno."')";
$query.="INSERT into
receipt(statementno,accountnum,dateofpayment,amount,submittedby)
VALUES('".$statementno."','".$accno."','".$dateofpayment."','".$amount."','".$submittedby."')";
/* execute multi query */
if (mysqli_multi_query($con, $query)) {
do {
/* store first result set */
if ($result = mysqli_store_result($con)) {
while ($row = mysqli_fetch_row($result)) {
printf("%s\n", $row[0]); // Or whatever...
}
mysqli_free_result($result); // Free in order to store the next
}
}
} while (mysqli_next_result($con));
}
于 2014-02-28T08:49:17.103 回答