故障排除“通知:未定义的索引”错误

时间:2011-11-05 20:50:49

标签: php mysql

任何人都可以查看我的代码,为什么我会收到这样的通知?

  

注意:第76行的C:\ xampp \ htdocs \ HRPO \ module \ reports \ jo \ view_jo.php中的未定义索引:id

第76行:

$id=$_GET['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>";
?>

和找到第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>";

}

?>

提前感谢所有建议和帮助。

2 个答案:

答案 0 :(得分:1)

$_GET['id']预计网址中的get变量“id”(即www.google.com?id=4,然后$_GET['id']将等于4)。

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

之前执行此操作

编辑:实际错误最后是假设需要使用$_GET而不是$_POST表单数据的可能性。

答案 1 :(得分:0)

看起来选择框是SSA_ID,但您使用的是$ _GET ['id'],请尝试将其更改为$ _GET ['SSA_ID'];