How to work with if and else?

1

Good morning.

I would like to get help from you to build this code because I am not able to implement it.

$query1 = "INSERT INTO paciente VALUES ('NULL, $nome_paciente, $nome_doutor')";

$id_paciente = mysql_insert_id();

$query2 = "INSERT INTO servico VALUES ('NULL, tipo_servico, data_servico,{$id_paciente})";

$id_servico = mysql_insert_id();

$query3 = "INSERT INTO estagio VALUES ('NULL, {$id_servico}, data_estagio, tipo_estagio')";

In the following pattern:

if (@mysql_query(INSERT INTO cad_paciente VALUES (NULL, $nome_paciente, $nome_doutor))) {

if(mysql_affected_rows() == 1){
    echo "Registro efetuado com sucesso<br />";
}

}

In this pattern above I can only insert one record in a table as I do to continue insertion.

    
asked by anonymous 06.05.2016 / 15:56

0 answers