Edit:I added this
if (isset($_POST['delete']) && isset($_POST['checkbox'])) (get from an answer below but it seems the asnwer is gone)
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...
<form name="frmSearch" method="post" action="insert-add.php">
<table width="600" border="1">
<tr>
<th width="50"> <div align="center">#</div></th>
<th width="91"> <div align="center">ID </div></th>
<th width="198"> <div align="center">First Name </div></th>
<th width="198"> <div align="center">Last Name </div></th>
<th width="250"> <div align="center">Mobile Company </div></th>
<th width="100"> <div align="center">Cell </div></th>
<th width="100"> <div align="center">Workphone </div></th>
<th width="100"> <div align="center">Group </div></th>
</tr>
</form>
<?
echo "<form name='form1' method='post' action=''>";
while($objResult = mysql_fetch_array($objQuery))
{
echo "<tr>";
echo "<td align='center'><input name=\"checkbox[]\" type=\"checkbox\" id=\"checkbox[]\" value=\"$objResult[addedrec_ID]\"></td>";
echo "<td>$objResult[addedrec_ID] </td>";
echo "<td>$objResult[FirstName]</td>";
echo "<td>$objResult[LastName] </td>";
echo "<td>$objResult[MobileCompany] </td>";
echo "<td>$objResult[Cell] </td>";
echo "<td>$objResult[WorkPhone] </td>";
echo "<td>$objResult[Custgroup] </td>";
echo "</tr>";
}
echo "<td colspan='7' align='center'><input name=\"delete\" type=\"submit\" id=\"delete\" value=\"Delete\">";
if (isset($_POST['delete']) && isset($_POST['checkbox'])) // from button name="delete"
{
$checkbox = ($_POST['checkbox']); //from name="checkbox[]"
$countCheck = count($_POST['checkbox']);
for($d=0;$d<$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->GetSelfScript();
}
else
{
echo "Error: ".mysql_error();
}
}
echo "</form>";
Thanks for every reply.