Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

125
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda