1
I am making a registration system and would like a help from you to be able to save the data in several tables.
My registration is composed by the following fields.
Nome do Paciente
Nome do Doutor
Tipo de Serviço
Data de Entrada
Estagio
Now so is my database table:
id_paciente
nome_do_paciente
nome_do_doutor
This data will be saved in the patient table and accurate the id of this record to give sequence.
id_servico
tipo_servico
data_servico
id_paciente
This data will be saved in the service table and I also need the id of this record.
id_estagio
id_servico
data_estagio
tipo_estagio
This data will be saved in the stage table and also need the id of this record.
Abre_Conexao();
if (@mysql_query(INSERT INTO cad_paciente VALUES (NULL, $nome_paciente, $nome_doutor))) {
if(mysql_affected_rows() == 1){
echo "Registro efetuado com sucesso<br />";
}
}
I’ve seen it working this way below but I want to add to this pattern above because my code is all in it
$query1 = "INSERT INTO paciente VALUES ('NULL, $nome_paciente, $nome_doutor')";
mysql_query( $query1 );
$id_paciente = mysql_insert_id();
$query2 = "INSERT INTO servico VALUES ('NULL, tipo_servico, data_servico,{$id_paciente})";
mysql_query( $query2 );
$id_servico = mysql_insert_id();
$query3 = "INSERT INTO estagio VALUES ('NULL, {$id_servico}, data_estagio, tipo_estagio')";
mysql_query( $query3 );
And php goes where in this story?
– rray
I edited the question informing better what I need
– Cristiano Cardoso Silva