I'm getting information from a select, which pulls the states and cities registered in the database. In the value of each select (city and state) is the id of them in the table (only this way to work with the function in AJAX). But at the time of inserting I am not able to make this id of the state and city in the name of the city ( select * from cidade where id = $_post[cidade]
). Putting mysqli_query
into the PHP variable and then trying to insert it gives an error.
$cidade = $_POST['cidade'];
$estado = $_POST['estado'];
//Validando dados do formulário
if(!empty($nome) && !empty($endereco) && !empty($num) && !empty($CEP) && !empty($bairro) && !empty($cidade) && !empty($estado)){
//Caso todos os campos sejam preenchidos, insere os valores na tabela estabelecimento
mysqli_query($conectar, "INSERT INTO estabelecimento VALUES (NULL, '$nome', '$CNPJ', '$endereco',
'$num', '$comp', '$CEP', '$bairro', '$cidade', '$estado', 0)");
The first two records were entered manually into the database.