The following describes how to delete records in php.
The code is as follows:
@ Mysql_connect ("localhost", "root", "1981427") // you must connect to the database server before selecting a 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 ");
$ Query = @ mysql_query ("select * from tablename1") // execute an SQL statement
Or die ("SQL statement execution failed ");
Echo "";
?>
The code is as follows:
@ Mysql_connect ("localhost", "root", "1981427") // you must connect to the database server before selecting a 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 "deleted successfully ";
Else
Echo "failed to delete ";
}
Mysql_close ();
?>