Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

124
Views
insert in multiple column with different id

This is what my database table looks like:

 id  | role    | adviser    
 1   | section |  
 2   | teacher |  

I want to insert a new section and update the existing teacher with the adviser column. Is this possible?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

with pdo,while you have connected successfully

require_once 'includes/db_connect.php';

And as you have get the values with select and assigned them to variables $sectionfromadviser and $teacherfromadviser you can procedure like this

try{

                //update the verify column from users
    $sql="UPDATE tablename SET section=:section,teacher=:teacher WHERE id = :id";


    $stmt= $db->prepare($sql);
    $stmt->bindParam(':section', $sectionfromadviser);       
    $stmt->bindParam(':teacher', $teacherfromadviser);    
    $stmt->bindParam(':id', $id);
    $stmt->execute();


}catch(PDOException $e){

   if(!$stmt->execute()){

     throw $e;
   }

}catch (Exception $e) {

  throw $e;
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!