I need to make an insert in the gynecology
table, this table has no rows.
the session variable is 2 in another page.
$_SESSION ["id_patient"] = 2;
<?php
$insert = $db->prepare("INSERT INTO gynecology(id_patient, nvisita, date_visit, background, reason_visit, exploration, exploration_comp, diagnosis, treatment)
SELECT IFNULL(gy.id_patient,:id_patient), IFNULL(max(gy.nvisita),0)+1, (now()), :background, :reason_visit, :exploration, :exploration_comp, :diagnosis, :treatment
FROM gynecology gy, patients pa
WHERE gy.id_patient = pa.id
AND PA.ID = :id_patient");
$insert->bindParam(":background", $background);
$insert->bindParam(":reason_visit", $reason_visit);
$insert->bindParam(":exploration", $exploration);
$insert->bindParam(":exploration_comp", $exploration_comp);
$insert->bindParam(":diagnosis", $diagnosis);
$insert->bindParam(":treatment", $treatment);
$insert->bindParam(":id_patient", $_SESSION["id_patient"]);
$insert->execute();
?>
The patients
table contains the id of the patient.
thanks.