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

87
Visualizações
Get id from other table then insert into table. I want to click the button then answer current question
<?php require_once('connection.php');  
session_start();

if (isset($_POST['Submit']))
{  
    $answ = $_POST['answ'];      
    $email = $_SESSION['email']; 


    $insert = "INSERT INTO answerList (answ,queID,email) SELECT questionList.queID FROM questionList   " ;
    $result = mysqli_query($con, $insert);
 
    if (!$result) {
        echo "<script>alert('ERROR !!!!! '); location='faq.php';</script>";
    }
    else {
        echo "<script>alert('Successful Post'); location='faq.php'; </script>";
    }
    


}
?> 

I have 3 table table 1: users(email, password) table 2: question(questionID, questionContent, email) table 3: answer(answerID, answerContent, questionID, email)

how can i connect questionID into table 3? i already do the login and add question sql . but how can i add the answer to current question with logged email?

a table have question. and each question have answer button

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You could use <input type='hidden' name='questionId' value='<?php echo $value>'>

For each question you'll have to set $value to the questionID.

When the answer is submited you'll do:


if (isset($_POST['Submit']))
{  
    $answ = $_POST['answ'];      
    $email = $_SESSION['email']; 
    $questionId = $_POST['questionId'];


    $insert = "INSERT INTO `answerList`(`answer`, `email`, `questionID`) VALUES ('$answ','$email','$questionId[value-3]')" ;
    $result = mysqli_query($con, $insert);
 
    if (!$result) {
        echo "<script>alert('ERROR !!!!! '); location='faq.php';</script>";
    }
    else {
        echo "<script>alert('Successful Post'); location='faq.php'; </script>";
    }
    


}
about 4 years ago · Juan Pablo Isaza 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