我需要在for (int i = tokens.Length - 6, i < tokens.Length; i++)
{
string searchHist = tokens[i];
if(userSettings.Length > refer)
{
output.Append("<li>" + searchHist + "</li>");
}
}
表中进行插入,此表没有行。
另一个页面中的会话变量为2。
gynecology
$_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();
?>
表包含患者的ID。
感谢。
答案 0 :(得分:0)
你是错配的参数。改变:
$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");
// this first parameter is missing
$insert->bindParam(":id_patient", $_SESSION["id_patient"]);
// the other parameters you have
$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"]);