-1
Well I have two INSERT in the same file, and I want the id of the first INSERT(Tabela1) also go to my second INSERT(table2), I really do not know how to do, I will leave everything more detailed below.
INSERT 1 Advertisement
$query = "INSERT INTO criar_anuncio (nome_funcionario, tipo_anuncio, cidade, cep, endereco, numero_casa, bairro, visibilidade, telefone, wpp, id_user_anun, data_cadastro) VALUES ('$post_funcionario', '$tipo_anuncio', '$cidade', '$cep', '$endereco', '$num_casa', '$bairro', '$visibilidade', '$telefone', '$wpp', '$id_user_anun', NOW())";
Until then a normal INSERT. Now I wanted the id that is auto increment to go to my second table. INSERT 2 Photos of the rooms
$query_comodos = "INSERT INTO `img_comodos`( `id_user`, `id_anuncio`, `img_file`) VALUES ('$id_user_anun', '$img_final_comodo')";
Well, I’m trying to get my table id Announcement to my table Photos Comfortable, with each id occupying the field id_anuncio on my table 2.
Here is my second table, and I want to occupy the field id_anuncio
Take a look at
last insert id
, I think that’s what you need– Papa Charlie