Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

85
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda