michael789
asked on
delete multiple records
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?
I also don't understand "if($_GET['justdel'])". Why do I have to have this again?
<?php
/* 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
if($_GET['justdel'])
{
for ($i=0; $i<$count; $i++)
{
$sql = mysql_query("delete from tabledelete where id=$id[$i]");
}
if ($sql)
{
print "Record successfully deleted<br>";
print "<a href=view.php>Click here to go back</a>";
}
}
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.