I need to delete multiple records for a database table using a specific id that I receive via URL parameter from the previous page. I found a code similar to this however I am not sure if this would loop to the records as for each specific id I need to delete several records.
I also don't understand "if($_GET['justdel'])". Why do I have to have this again?
/* delete.php */
$host = "localhost";
$username = "root";
$password = "";
$database = "delsampel";
$connection = mysql_connect($host, $username, $password);
mysql_select_db($database, $connection) or die("MysQL Error");
$id = $_GET[del];
$count = count($id); //counting how many rows to delete
for ($i=0; $i<$count; $i++)
$sql = mysql_query("delete from tabledelete where id=$id[$i]");
print "Record successfully deleted<br>";
print "<a href=view.php>Click here to go back</a>";