The task is banal, but I do not understand how to do it. It is necessary to make it so that from the list of elements it is possible to delete several elements at once. In the shape of

<form name="del_id" action="delete.php" method="GET"> <input type="checkbox" name="del_id" value="1"> <input type="checkbox" name="del_id" value="2"> <input type="checkbox" name="del_id" value="3"> </form> 

In the address bar I get, for example, delete.php? Del_id = 2 & del_id = 3 But how can I get different values ​​of the same variable from the $ _GET array? When different variables - everything is clear. When the value is the same, everything is clear. And here you need to somehow count and parse the variables $ _GET-array and insert into the SQL query. Tell me please.

  • the value of the name = "" attributes must be different, your example contradicts the standards - Arsen
  • Thanks for the hint with 'name', but my difficulty is in processing the request - what kind of cycle should I do? - Sergey Tolkachev

2 answers 2

name="del_id[]" to write variables to an array and pass as in your example. And getting the array $_GET['del_id'] = array('2', '3'); redo the processing request

  • Thanks for the hint with 'name', but my difficulty is in processing the request - what kind of cycle should I do? - Sergey Tolkachev

Solved the problem with the foreach loop.

Handler:

 if (isset($_GET['del_id'])) {$del_id = $_GET['del_id'];} foreach ($del_id as $v) { $result = mysql_query ("DELETE FROM locality WHERE id='$v'"); } 
The only bad thing is that each deletion is a separate request here. But in general, the problem is solved.

  • can be $str_id = implode (",", $_GET['del_id']); mysql_query ("DELETE FROM locality WHERE id IN (".$str_id.")"); one query: $str_id = implode (",", $_GET['del_id']); mysql_query ("DELETE FROM locality WHERE id IN (".$str_id.")"); $str_id = implode (",", $_GET['del_id']); mysql_query ("DELETE FROM locality WHERE id IN (".$str_id.")"); - Sergey Strelchenko