如何在另一个表中插入新值后检索数据

时间:2017-10-04 15:45:05

标签: php mysqli

<?php include('dbcon.php'); 
include('header.php');

    //variable
    $clientID='';
    $billAmount='';
    $arrear='';
    $monthlyBill='';
    $surcharge='';


    //data add

    $clientID=$_POST['clientID'];


    $sqll = "SELECT  `client`.`clientId` , (
         `arrear` + `surcharge` + `monthlyBill`) AS  'billamount', (

        FROM  `billifno` 
        JOIN  `client` ON  `billifno`.`clientID` =  `client`.`clientID` WHERE  `billifno`.`clientID`='".$_POST["clientID"]."'";


    $result = mysqli_query($con,$sqll);

//  if ($result->num_rows > 0) 


    // output data of each row
    while($row = mysqli_fetch_assoc($result)) {

        $clientId = $row['clientId'];
        $arrear = $row['arrear'];
        $monthlyBill= $row['monthlyBill'];
        $billAmount = $row['billAmount'];
        $surcharge = $row['surcharge'];

    }   


        //echo $billAmount;



    $sql = "INSERT INTO `billIfno`
    (`clientID`, `billAmount`,`arrear`,  `monthlyBill`,`surcharge`) VALUES 
    ('$clientID','$billAmount','$arrear','$monthlyBill','$surcharge')";
    if ($con->query($sql)=== true)
    {
    echo "Recorded!!!";
    }
    else
    {
    echo "Not Recorded !!!";
    }


    $con->close();
?>

Hare我正在采取一些价值并使用查询处理它然后再次插入 billInfo 表但不插入新值如 如果我回显 billAmonu ,它将打印由查询bt计算的正确值,该值未插入数据库。

0 个答案:

没有答案