#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    22
    Rep Power
    0

    SQL Query doesnt Insert Data Properly


    Hi,

    We have a shopping cart with a basket. When the user is checked out the following query is executed

    PHP Code:
        $sql1="SELECT * FROM basket WHERE sessionID='".$sid."'";
        
    $rs1=mysql_query($sql1);
        while(
    $row=mysql_fetch_array($rs1))
        {
            
    $bwrID=$row['borrowerID'];
            
    $lenID=$row['LandID'];
            
    $amount=$row['amount'];
            
    $loanid=$row['loanID'];
            
    $result=$db->insert_field('transactiondetail_temp','transactionID,loanID,borrowerID,LandID,Amount'"'".$lastTransId."','".$loanid."','".$bwrID."','".$_SESSION['LandID']."','".$amount."'");
        } 
    When we have a look at the back DB. The following fields are populated

    borrowerID
    LandID
    amount

    but the loanID is only populated for the first item in the cart if there are say 3 items, the first one has the loanID populated whereas for the remaining 2 items it shows the LoanID as '0'.

    For basic understanding, each borrower ID is associated with Loan ID and these values are properly generated in the DB in another table called Loan which inserts the values into the basket into the transactiondetail_temp table.

    Can any advise as to what could be the problem.
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Location
    The Pleiades
    Posts
    294
    Rep Power
    8
    Good morning,

    You could, for testing purposes, run var_dump($row) just inside the while loop

    Regards,

    NM.

IMN logo majestic logo threadwatch logo seochat tools logo