Jump to content

how to delete selected record


manojhooda

Recommended Posts

Let's say you have a checkbox and it's value represents the ID number of a table in your database:

<input type="checkbox" name="mycheck" value="24">

 

We can check if it has been ticked and if yes, use the value from it to delete a record:

if ($_POST['mycheck']) {
  $checkval=$_POST['mycheck'];
  if (mysql_query("DELETE FROM table WHERE id=".$checkval." LIMIT 1")) {
    echo 'Deleted';
  } else {
    echo 'Not deleted';
  }
}

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.