0
I have the following tables:
1 - Assignments with the following fields: Id, Request, Collaborator and Date Assignment.
2 - States with the following fields: id, State and State.
Numpedido is equal to Idestado.
Now I want you to insert me in the Attribution table to enter me in the State table, but I want you to fetch me the value of the Numrequest of the first table automatically and insert me in the State table in the State field.
If I were to pick up the id I would use the following code:
$sql = "INSERT INTO AtribuicaoLuvas (NumPedido,Colaborador,DataAtribuicao)
VALUES ('$pedido','$colaborador','$data')";
if ($conn->query($sql) === TRUE) {
$last_id = $conn->insert_id;
}
$sql1 = "INSERT INTO EstadoLuvas (`IdEstado`,`Estado`)
VALUES ('$last_id','$estado')";
if ($conn->query($sql1) === TRUE);
but in this case as I do?
Can you explain better? I don’t quite understand what you want
– Kayo Bruno
In the first insert the value of the
NumPedido
is =$pedido
, thence in the second Insert make the value of theIdEstado
=$pedido
– user60252
Leo Caracciolo, thanks for the tip. I solved my problem
– user87525