472,146 Members | 1,317 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,146 software developers and data experts.

Deleting multiple Rows Using Checkbox

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

$sql = "Select * from list;";
$result=mysql_query($sql) or die ("<br> Could not Retrieve Data <br>");

While ($row =mysql_fetch_array($rs))
$currentCom_id = $row["com_id"];

<input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $row['com_id']; ?>">


<input name="delete" type="submit" id="delete" value="Delete">

Now for deleting the selected checkbox i have used following SQL queries.


if($_POST['delete'] == "Delete"){
$del_id = $checkbox[$j];
$sql = "DELETE FROM committee WHERE com_id='$del_id'";
$result = mysql_query($sql);
echo $result;


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 ...
Apr 8 '07 #1
4 11365
code green
1,726 Expert 1GB
Looks like you are expecting the GLOBAL post vars to be switched on. It is switched off by default in later versions of php. You should not use this anyway. You need to read the checkbox values through the $_POST array
Apr 10 '07 #2

i'm gaing the same problem... I change my code to that:

// Check if delete button active, start this
if($_POST['delete'] == 'Delete'){
$del_id = $_POST['checkbox'][$i];
$sql = "DELETE FROM $tbl_name WHERE userid='$del_id'";
$result = mysql_query($sql);

// if successful redirect to delete_multiple.php
echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.php\">";

But it still doesn't work...

Please help.
Jun 11 '07 #3
1,351 Expert 1GB
what errors are u getting?
Jun 11 '07 #4
Hi, If any one didn't got the solution yet of this problem and still seeking! Please mail me on DELETED
Feb 13 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by cool_dude7244 | last post: by
4 posts views Thread by MasterChief | last post: by
11 posts views Thread by giloosh | last post: by
reply views Thread by Saiars | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.