I have two related tables and I want to get the last ID_primeraTabla
to insert it in the second table since the ID_primeraTabla
is the foreign key. any ideas ?
What I have is the following
$pregunta = $_POST["pregunta"];
$respuesta = $_POST["respuesta"];
$comentario = $_POST["comentario"];
$sql = "Select id_asistente FROM Asistente order by id_asistente DESC LIMIT 1";
mysqli_query($connect, $sql) or die (mysqli_error($connect));
$query = "Insert into Encuesta_asistente(pregunta_encuesta,respuesta_encuesta,comentario_encuesta,id_asistente) values ('$pregunta','$respuesta','$comentario','$sql');";
mysqli_query($connect, $query) or die (mysqli_error($connect));
mysqli_close($connect);