I have a php file called on POST from my android app. Currently I have a query that inserts post values to my violator table. And two of that values are officer name and reference . Now What I want to do is also run another query that will update the reference on my user_tbl where officer_name = oname. Officer_name is the column from the user_tbl and oname is the posted variable name. How or in what way can I achieve that?
Here is the php code.
<?php
$user_name = "dodolp";
$password = "dodolp";
$server = "localhost";
$db_name = "TMTRO";
$con = mysqli_connect($server,$user_name,$password,$db_name);
if ($con){
$Name = $_POST['name'];
$LName = $_POST['lname'];
$LNumber = $_POST['lnumber'];
$Violation = $_POST['violation'];
$Aplace = $_POST['aplace'];
$Address = $_POST['address'];
$PNumber = $_POST['pnumber'];
$OName = $_POST['oname'];
$RNumber = (int) $_POST['rnumber'];
$DTime = $_POST['dtime'];
$query = "insert into violators (name,lname,lnumber,violation,aplace,address,pnumber,oname,reference,datetime) values ('".$Name."','".$LName."','".$LNumber."','".$Violation."','".$Aplace."','".$Address."','".$PNumber."','".$OName."','".$RNumber."','".$DTime."');";
$sql = "UPDATE into user_tbl SET reference = '$RNumber' WHERE officer_name = '$OName'";
$result = mysqli_query ($con, $query);
if ($result)
{
$status = 'OK';
}
else
{
$status = 'FAILED';
}
}
else { $status = 'FAILED'; }
echo json_encode(array("response"=>$status));
mysqli_close($con);
?>