Home >Backend Development >PHP Tutorial >PHP delete record implementation code
Copy the code The code is as follows:
@mysql_connect("localhost", "root","1981427") //You need to connect to the database server before selecting the database
or die("Database server Connection failed");
@mysql_select_db("test") //Select database mydb
or die("Database does not exist or is unavailable");
$query = @mysql_query("select * from tablename1") //Execute SQL Statement
or die("SQL statement execution failed");
echo "
Copy code The code is as follows:
@mysql_connect("localhost ", "root","1981427") //You need to connect to the database server before selecting the database
or die("Database server connection failed");
@mysql_select_db("test") //Select the database mydb
or die(" The database does not exist or is unavailable");
foreach($_POST['chk'] AS $check)
{
$query = mysql_query("delete from tablename1 where id = $check");
if($query)
echo "Deletion successful";
else
echo "Deletion failed";
}
mysql_close();
?>
The above introduces the PHP deletion record implementation code, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.