$ids = $_POST['ids'];
// sky***earth***sea***sun***...
$ids = explode("***", $ids);
foreach ($ids as $id) {
$st = $db->query("delete from tags where id = " . $id);
}
Is there a more elegant way to delete multiple rows, especially regarding peformances in case of huge array? Something like:
$st = $db->query("delete from tags where id in " . $ids);
Any suggestion?
idis a text column i.e.sky,earthetc Then the$idneeds to be wrapped in quotes like$st = $db->query("delete from tags where id = '$id' ");But do pay heed to the SQL Injection Attack Even if you are escaping inputs, its not safe! Use prepared parameterized statements in either theMYSQLI_orPDOAPI's