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

80
Views
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 answers
Answer question

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 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!