Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need to update row and display the updated row.

In my below code update query is working. But cannot display.

What I have tried:

<?php
include_once 'db.php'


if(isset($_GET['PID'])){


$id=$_GET['PID'];



$sql = "UPDATE assign t2,
( SELECT PID,pname,pemail,ph_no,experience
FROM addpandit
) t1
SET t2.PID = t1.PID,t2.pname = t1.pname,t2.pemail = t1.pemail,t2.ph_no = t1.ph_no,t2.experience = t1.experience
WHERE t2.PID='' AND t1.PID=$id";
$insert_user=$conn->query($sql);


$sql1="SELECT * FROM assign WHERE PID=$id";
$result=$connect->query($sql1);
$rows=$result->fetch_assoc();
echo ($rows['AID']);

}
?>
Posted
Updated 8-Jun-17 2:42am

We don't have your database or even know how it is organised. So only you can find the problem.

Is there an AID field in the assign table?

Add error checks for each call and report errors.
For debugging you might also report success for each command like
PHP
if ($result) {
    echo "Found recordset\n";
} else {
    echo "Recordset not found\n";
}
 
Share this answer
 
Another thing about php returns from SQL queries: They're in the form of an array of rows - even if you only get one row.

Thus, your data request:
echo ($rows['AID']);

would need to look like:
echo ($rows[0]['AID']);

Best way to see if you're getting what you think you're getting?
print_r($rows)
and see what data was returned and how it's indexed in the array.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900