1

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
                    }   
                }
            }
        }
}
}
9
  • I'm not lying i can show the whole code Commented Jun 5, 2011 at 14:47
  • i don't know that value=$row[0] or value='$row[0]' row[0] is integer it may be the error or not? i tried them too Commented Jun 5, 2011 at 14:57
  • i had changed my code my problem was solved there but for normalization I changed whole of my tables and now it has again error i tried the corrected one on that situation and updated it but the problem still is in it Commented Jun 5, 2011 at 14:59
  • Has 'p' been defined in a previous statement? I don't think so. Which means in the 'echo' statement, name='p[$i]' should just be name='p[]'since 'p' is supposed to hold an array of values from checkboxes. Commented Jun 5, 2011 at 15:00
  • can you send the result of print_r($_POST) for your script ? Commented Jun 5, 2011 at 15:00

1 Answer 1

1

I think the following line gives problem

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

Try this

echo"<td><input type='Checkbox' name='p[]'  ...
Sign up to request clarification or add additional context in comments.

2 Comments

now it shows me some errors i think you are right because it can go to for each now and send me errors
Just a reminder: Actually it is beyond what u asked in this post already. If you have another problem you should do in another post :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.