gpt4 book ai didi

php - 故障排除 "Notice: Undefined index"错误

转载 作者:行者123 更新时间:2023-11-29 14:40:52 26 4
gpt4 key购买 nike

有人可以检查我的代码为什么我会收到这样的通知吗?

Notice: Undefined index: id in C:\xampp\htdocs\HRPO\module\reports\jo\view_jo.php on line 76

第 76 行:

$id=$_GET['id'];

这是我获取我的 id 的第一个 jar :

  <?php
echo "<dl>";
echo "<dt width = 200 id=\"label\">"."SSA"."</dt>";
echo "<dd align='right'>";
$result = mysql_query("SELECT ssa.first_name,ssa.SSA_ID
FROM staffing_specialist_asst ssa
left join jo_partner jp on jp.SSA_ID = ssa.SSA_ID
group by first_name") or die(mysql_error());
$dropdown = "<select name=\"SSA_ID\" style=\"position:relative; left:-51px;\">\n";
while($row = mysql_fetch_assoc($result)) {
$dropdown .= "\r\n<option value='{$row['SSA_ID']}'>{$row['first_name']}</option>";
}
$dropdown .= "\r\n</select>";

echo $dropdown;
echo "</dd>";
echo "</dl>";
?>

以及第 76 行所在的第二个代码:

<?php

$id=$_GET['id'];

if(isset($_POST['submit']))
{
$datefrom = $_POST['timestamp'];
$dateto = $_POST['timestamp1'];

//echo $option;


$_SESSION['datefrom'] = $datefrom;
$_SESSION['dateto'] = $dateto;



if(( $datefrom == NULL) || ($dateto == NULL)){
echo "<SCRIPT LANGUAGE='javascript'> confirmationError() ;</SCRIPT>";
exit();

}


$final =("SELECT distinct jp.receivedDate as rDate, ssa.first_name as saFName, ssa.last_name as saLName,job.client_order_number as joNum,
job.job_order_type as joType, job.job_title as joTitle, cl.name as clientName
,ss.first_name as ssFName,ss.last_name as ssLName,jp.acknowledgeDate as aDate, stat.status as stat
FROM staffing_specialist_asst ssa
left join jo_partner jp on ssa.SSA_ID = jp.SSA_ID
left join job_order job on jp.job_order_number = job.job_order_number
left join jo_status stat on job.job_order_number = stat.job_order_number
left join staffing_specialist ss on jp.SS_ID = ss.SS_ID
left join client cl on job.client_ID = cl.client_ID
where jp.receivedDate between '$datefrom1' and '$dateto1'
and ssa.SSA_ID='$id'
group by jp.receivedDate
order by jp.receivedDate asc");

echo $final;

$query = mysql_query($final);

echo "<table>";

while($row = mysql_fetch_array($query))
{
$rDate = $row['rDate'];
$saFName = $row['saFName'];
$saLName = $row['saLName'];
$joNum = $row['joNum'];
$joType = $row['joType'];
$joTitle = $row['joTitle'];
$clientName = $row['clientName'];
$ssFName = $row['ssFName'];
$ssLName = $row['ssLName'];
$aDate = $row['aDate'];
$stat = $row['stat'];

echo "<tr>";
echo "<td width='150' colspan=\"1\" align=\"center\">".$rDate."</td>";
echo "<td width='150' colspan=\"1\" align=\"center\">".$saFName."".$saLName."</td>";
echo "<td width='150' colspan=\"1\" align=\"center\">".$joNum."</td>";
echo "<td width='150' colspan=\"1\" align=\"center\">".$joType."</td>";
echo "<td width='150' colspan=\"1\" align=\"center\">".$joTitle."</td>";
echo "<td width='150' colspan=\"1\" align=\"center\">".$clientName."</td>";
echo "<td width='150' colspan=\"1\" align=\"center\">".$ssFName."".$ssLName."</td>";
echo "<td width='150' colspan=\"1\" align=\"center\">".$aDate."</td>";
echo "<td width='150' colspan=\"1\" align=\"center\">".$stat."</td>";
echo "</tr>";

}

echo "</table>";

}

?>

预先感谢您的所有建议和帮助。

最佳答案

$_GET['id'] 期望在网址中获取变量“id”(即 www.google.com?id=4 然后 $ _GET['id'] 等于 4)。

为了避免这种情况,您可以在检查获取值之前执行此操作if (!empty($_GET)) {$id = $_GET['id']}

编辑:实际错误最终是假设需要使用 $_GET 而不是 $_POST 来获取表单数据。

关于php - 故障排除 "Notice: Undefined index"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8023184/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com