[英]Troubleshooting “Notice: Undefined index” error
could anyone check my code why i get a notice like this? 谁能检查我的代码,为什么我收到这样的通知?
Notice: Undefined index: id in C:\\xampp\\htdocs\\HRPO\\module\\reports\\jo\\view_jo.php on line 76
注意:未定义的索引:第76行的C:\\ xampp \\ htdocs \\ HRPO \\ module \\ reports \\ jo \\ view_jo.php中的id
line 76: 第76行:
$id=$_GET['id'];
here is the first could of which I get my id
: 这是我得到我的
id
:
<?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>";
?>
and the second code where line 76 is found: 第二行第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>";
}
?>
Thanks in advance for all the suggestions and help. 在此先感谢您的所有建议和帮助。
$_GET['id']
expected the get variable 'id' in the url (ie www.google.com?id=4
then $_GET['id']
would equal 4). $_GET['id']
预期网址中的获取变量'id'(即www.google.com?id=4
然后$_GET['id']
等于4)。
In order to avoid this you could do this before checking the get value if (! empty($_GET)) {$id = $_GET['id']}
为了避免这种情况,您可以在检查get值
if (! empty($_GET)) {$id = $_GET['id']}
EDIT: The actual error ended up being the assumption of needing to use $_GET
instead of the possibility of $_POST
for form data. 编辑:实际错误最终是需要使用
$_GET
而不是表单数据$_POST
可能性的假设。
看起来选择框是SSA_ID
但您使用的是$ _GET ['id'],请尝试将其更改为$ _GET ['SSA_ID'];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.