我的patient_display.php代码调用传递P_ID的patient_history.php文件。以下是我的代码。
patient_display.php:
echo '<form name="Patient" action="patient_history_display.php" method="get">';
$pid=$_GET["patient_id"];
echo '<input type="text" name="p_id" value= '.$pid.' >';
</form>
patient_history.php:
$result = mysqli_query($con,"SELECT P.P_F_NAME, P.P_L_NAME,P.P_ADDR, round(datediff(now(),P.P_DOB)/365) AS P_AGE, D.D_DESC, A.A_DESC
FROM P_HAS_A PA, patient P, P_HAS_D PD, n_provide_m NM, disease D, allergy A
WHERE P.P_ID = PD.P_ID AND PD.D_ID = D.D_ID AND P.P_ID = PA.P_ID AND PA.A_ID = A.A_ID AND P.P_ID='{$_GET["p_id"]}';");
$pid=$_GET["p_id"];
然而,它抛出以下错误 SCREAM:忽略错误抑制 注意:未定义的索引:
中的p_id答案 0 :(得分:0)
在使用$ _GET和$ _POST之前检查它的值是否设置(存在)。 你可以使用'@','isset','strlen'和'!empty'。 所以你的情况将是
if(isset($_GET['patient_id'])) {
$id = $_GET['patient_id'];
echo '<input type="text" name="p_id" value= '.$pid.' >';
}
和$_GET['p_id']
答案 1 :(得分:0)
我认为你在sql中有错误。试试这个:
$pid=$_GET["p_id"];
$result = mysqli_query($con,"SELECT P.P_F_NAME, P.P_L_NAME,P.P_ADDR, round(datediff(now(),P.P_DOB)/365) AS P_AGE, D.D_DESC, A.A_DESC
FROM P_HAS_A PA, patient P, P_HAS_D PD, n_provide_m NM, disease D, allergy A
WHERE P.P_ID = PD.P_ID AND PD.D_ID = D.D_ID AND P.P_ID = PA.P_ID AND PA.A_ID = A.A_ID AND P.P_ID='$pid'");
答案 2 :(得分:0)
试试这个
echo '<form name="Patient" action="patient_history.php" method="get">';
$pid=$_GET["p_id"];
echo '<input type="text" name="p_id" value= '.@$pid.' >';
</form>
和patient_history.php:
$pid = $_GET['p_id'];
$result = mysqli_query($con,"SELECT P.P_F_NAME, P.P_L_NAME,P.P_ADDR,
round(datediff(now(),P.P_DOB)/365) AS P_AGE, D.D_DESC, A.A_DESC
FROM P_HAS_A PA, patient P, P_HAS_D PD, n_provide_m NM, disease D, allergy A
WHERE P.P_ID = PD.P_ID AND PD.D_ID = D.D_ID AND P.P_ID = PA.P_ID AND PA.A_ID = A.A_ID AND
P.P_ID='{$pid';");