简体   繁体   中英

Update table on the base of other table with php and oracle

I want to update table with unique result after searching the records one by one form other table on the base of House number. Example: I have one table named "Complaint Point" that have two columns "House No" and "Status" Other table named "Complaint Table" that have also two columns "House No" and "Status" but there are multiple entries of same House No. I wanted to compare each house number and status from table "Complaint Table",if any status present "OPEN" then it's update second table "Complaint Point" column status also "OPEN" and if all the status present "CLOSED in table "Complaint Table" then i update the first table "Complaint Point" column status "CLOSED".

I want this using the php and oracle.

I am doing this:

if (isset($_POST['btnSubmit']) == "Save")
{

    $STATUS = $_POST['COMPLAINT_STATUS'];
    $HOUSE_NO = $_POST['COMPLAINT_HOUSE_NO'];
$query ="SELECT STATUS FROM complainttable WHERE HOUSE_NO = '" . $_POST["COMPLAINT_HOUSE_NO"] . "' AND STATUS = 'CLOSED' ";
    $results = ociparse($conn, $query);
    ociexecute($results);
    while($row=oci_fetch_assoc($results)) {

    echo '<option>' . $row['STATUS'] . '</option>';

    if (isset($_POST['STATUS']) == "CLOSED")
    {
    $update = "UPDATE complaintpoint SET STATUS= 'CLOSED' where HOUSE_NO ='" . $_POST["HOUSE_NO"] . "' ";

    $send = oci_parse($conn, $update);
    oci_bind_by_name($send, ':STATUS', $STATUS);
    oci_execute($send);
    }

    else
    {
        echo '<option value="">Complaint is Still Open</option>';   
    }
    }
}

Below code will update

If any housenumber is OPEN in complaintTable then SET status=OPEN of that house number in complaintpoint table

     $query   =  "SELECT * FROM complainttable WHERE STATUS = 'OPEN' ";
     $results = ociparse($conn, $query);
     ociexecute($results);
        while($row=oci_fetch_assoc($results)) 
        {

                $update = "UPDATE complaintpoint SET STATUS= 'OPEN' where HOUSE_NO ='" . $row["HOUSE_NO"] . "' ";
                $send = oci_parse($conn, $update);
                oci_bind_by_name($send, ':STATUS', $STATUS);
                oci_execute($send);
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM