Hi ,
I am trying to figure out why my PHP code to delete multiple value by selecting the checkbox is not working. My php code is listed as below
[PHP]
<?php
$sql = "Select * from list;";
$result=mysql_query($sql) or die ("<br> Could not Retrieve Data <br>");
$num_rows=mysql_num_rows($result);
While ($row =mysql_fetch_array($rs))
{
$currentCom_id = $row["com_id"];
?>
<input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $row['com_id']; ?>">
.....
.....
<?php
}
?>
<input name="delete" type="submit" id="delete" value="Delete">
[/PHP]
Now for deleting the selected checkbox i have used following SQL queries.
[PHP]
if($_POST['delete'] == "Delete"){
for($j=0;$j<$num_rows;$j++){
$del_id = $checkbox[$j];
$sql = "DELETE FROM committee WHERE com_id='$del_id'";
$result = mysql_query($sql);
echo $result;
}
}
mysql_close();
?>
[/PHP]
The problem is when i press delete it does not deletes the rows selected, else it just reloads the page. I dont know where i am wrong.
can u guyz please help me on this ...
THanks