Jump to content

Delete All Rows with Check Box


unemployment

Recommended Posts

Do something like this:

 


<?php while($row = mysql_fetch_arrary($myQuery)) { ?>

<?php echo $row['title'];?> 

<input type="checkbox" name="delete_me[$row['ID']]">

<?php } ?>

 

Then after the form is posted...

 


$delete_me = $_REQUEST['delete_me'];

if(!empty($delete_me)) {

foreach($delete_me as $key => $value){

if($value == "on") {

mysql_query("DELETE * FROM yourTable WHERE ID = '$key'") or die(mysql_error())

}

}

}

Do something like this:

 


<?php while($row = mysql_fetch_arrary($myQuery)) { ?>

<?php echo $row['title'];?> 

<input type="checkbox" name="delete_me[$row['ID']]">

<?php } ?>

 

Then after the form is posted...

 


$delete_me = $_REQUEST['delete_me'];

if(!empty($delete_me)) {

foreach($delete_me as $key => $value){

if($value == "on") {

mysql_query("DELETE * FROM yourTable WHERE ID = '$key'") or die(mysql_error())

}

}

}

 

That didn't seem to work for me

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.