duanli0453 2011-06-05 14:41
浏览 47
已采纳

数组$ _POST中的问题

i have this code it can go to if(array_key_exists('p',$_POST)) but can't go to if(isset($_POST['p'][$i]) && $_POST['p'][$i]==$row[0])

i tried to echo $_POST['p'][0] in if(array_key_exists('p',$_POST)) but it tells me 0 is undefined

i don't know my error.

if(array_key_exists('update',$_POST)){
//somecode
echo"<td><input type='Checkbox' name='p[$i]'  value='$row[0]' unchecked onclick='openinput()'/></td>";
if(array_key_exists('p',$_POST))
        {
        $result=mysql_query($query);        
        if($result)
        {
            $num=mysql_num_rows($result);
            if($num>0)
            {
                if(isset($_POST['p'][$i]) && $_POST['p'][$i]==$row[0])
                {
                    foreach($_POST['p'] as $key=>$value)
                         {
                         //some code
                    }   
                }
            }
        }
}
}
  • 写回答

1条回答 默认 最新

  • doumizhi0809 2011-06-05 14:45
    关注

    I think the following line gives problem

    echo"<td><input type='Checkbox' name='p[$i]'  ...
    

    Try this

    echo"<td><input type='Checkbox' name='p[]'  ...
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?