MySQL Forums
Forum List  »  PHP

Insert in one table and update in another table
Posted by: Subrata Mukherjee
Date: March 10, 2020 11:14PM

I have two different tables say 'Student' and 'Result' with fields named 'ID' and 'Declared' in Student and 'ID' and 'Marks' in Result.

I wish to Insert the 95 as Marks in the ID number 5 also wish to Update 'Done' as in 'Declared' in 'Student'

I used the below code:

.
.
.
.

else{
$sql = "INSERT INTO Result (ID,Marks,..) values ('$ID','$marks',..);";
$sql.= "UPDATE Students SET Declared='Done' WHERE ID ='$ID'";


if($conn->query($sql)){
.
.
.

Please someone correct my code or suggest otherwise.

Options: ReplyQuote


Subject
Written By
Posted
Insert in one table and update in another table
March 10, 2020 11:14PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.