Undefined variable and index in delete multiple row function
<p>Edit:I added this</p>

<p>if (isset($_POST['delete']) &amp;&amp; isset($_POST['checkbox']))
(get from an answer below but it seems the asnwer is gone)</p>

<p>and now the undefined varialbe and index error are gone...but the problem now is when I try to delete , it require check and click delete button twice to delete the selected rows...</p>

<pre><code>  &lt;form name="frmSearch" method="post" action="insert-add.php"&gt;

&lt;table width="600" border="1"&gt;
  &lt;tr&gt;
    &lt;th width="50"&gt; &lt;div align="center"&gt;#&lt;/div&gt;&lt;/th&gt;
    &lt;th width="91"&gt; &lt;div align="center"&gt;ID &lt;/div&gt;&lt;/th&gt;
    &lt;th width="198"&gt; &lt;div align="center"&gt;First Name &lt;/div&gt;&lt;/th&gt;
    &lt;th width="198"&gt; &lt;div align="center"&gt;Last Name &lt;/div&gt;&lt;/th&gt;
    &lt;th width="250"&gt; &lt;div align="center"&gt;Mobile Company &lt;/div&gt;&lt;/th&gt;
    &lt;th width="100"&gt; &lt;div align="center"&gt;Cell &lt;/div&gt;&lt;/th&gt;
    &lt;th width="100"&gt; &lt;div align="center"&gt;Workphone &lt;/div&gt;&lt;/th&gt;
    &lt;th width="100"&gt; &lt;div align="center"&gt;Group &lt;/div&gt;&lt;/th&gt;
  &lt;/tr&gt;
    &lt;/form&gt;
&lt;?

    echo "&lt;form name='form1' method='post' action=''&gt;";

while($objResult = mysql_fetch_array($objQuery))
{


    echo "&lt;tr&gt;";
    echo "&lt;td align='center'&gt;&lt;input name=\"checkbox[]\" type=\"checkbox\" id=\"checkbox[]\" value=\"$objResult[addedrec_ID]\"&gt;&lt;/td&gt;";
    echo "&lt;td&gt;$objResult[addedrec_ID] &lt;/td&gt;";
    echo "&lt;td&gt;$objResult[FirstName]&lt;/td&gt;";
    echo "&lt;td&gt;$objResult[LastName] &lt;/td&gt;";
    echo "&lt;td&gt;$objResult[MobileCompany] &lt;/td&gt;";
    echo "&lt;td&gt;$objResult[Cell] &lt;/td&gt;";
    echo "&lt;td&gt;$objResult[WorkPhone] &lt;/td&gt;";
    echo "&lt;td&gt;$objResult[Custgroup] &lt;/td&gt;";

   echo "&lt;/tr&gt;";

}


 echo "&lt;td colspan='7' align='center'&gt;&lt;input name=\"delete\" type=\"submit\" id=\"delete\" value=\"Delete\"&gt;";

 if (isset($_POST['delete']) &amp;&amp; isset($_POST['checkbox'])) // from button name="delete"
 {
 $checkbox = ($_POST['checkbox']); //from name="checkbox[]"
     $countCheck = count($_POST['checkbox']);

 for($d=0;$d&lt;$countCheck;$d++)
     {
         $del_id  = $checkbox[$d];

 $sql = "DELETE from UserAddedRecord where addedrec_ID = $del_id";

 $result2=mysql_query($sql)  or trigger_error(mysql_error());;;

     }
         if($result2)
     {  
          $fgmembersite-&gt;GetSelfScript();
         }
         else
         {
 echo "Error: ".mysql_error();
         }
 }
  echo "&lt;/form&gt;";
</code></pre>

<p>Thanks for every reply.</p>
