SELECT following from INSERT

Asked

Viewed 62 times

0

I need to insert the latitude of the city into the latitude of the vessel, so I did this.

function cadastrarEmbarcacao($nome, $capacidade, $cidadePartida, $cidadeChegada, $horaViagem, $diaViagem){

    $sql = mysql_query("SELECT CID_LATITUDE FROM cidade");

    mysql_query("INSERT INTO embarcacao (EMB_NOME, EMB_CAPACIDADE, EMB_LATITUDE) VALUES ('$nome', '$capacidade', '$sql')") or die(mysql_error());
    echo "<script>alert('Embarcação Cadastrada com Sucesso!!');location.href='../view/cadastrarEmbarcacao.php';</script>";
}

Can anyone give me a light? Because I don’t know what to do.

  • 1

    From a look here https://answall.com/questions/167090/%C3%89-poss%C3%Advel-dar-Insert-com-select

  • Which return only from your select?

1 answer

1


You can do an Insert with select.

<?php 
mysql_query("insert into embarcacao(EMB_NOME, EMB_CAPACIDADE, EMB_LATITUDE) select '$nome', '$capacidade', CID_LATITUDE from cidade;");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.