I have the following tables:
1 - AssignmentsLogs with the following fields: Id, OrderNode, Contributor and DataAtribution.
2 - StateLoves with the following fields: id, StatusId, and Status.
The OrderID is equal to the IdEst.
Now I want that when I insert into the AssignList table that it also inserts me into the Switches table, but I want it to fetch the value of the FirstData from the first table automatically and insert me into the SwitchesList table in the IdState field.
If it was to get the id I used 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 how do I do it?