In this example you can learn how to delete records in the database table using mysql DELETE statement in the php application.
PHP MySQL DELETE Statement Example:
In this example you can learn how to delete records in the database table using mysql DELETE statement in the php application.
Syntax:
DELETE FROM table_name WHERE column_name = column_value
Example:
<?php $connection = mysql_connect("localhost","root","root"); if (!$connection) { die('PHP Mysql database connection could not connect : ' . mysql_error()); } else{ $db_name = "php_mysql"; mysql_select_db($db_name, $connection); $sql = "delete from user where user_id=1;"; $records = mysql_query($sql, $connection); echo "Delete record successfully."; } mysql_close($connection); ?>
Output:
Before running this example the database table records is:
After running this example the browser output is:
Delete record successfully.
And the database table records is:
[ 0 ] Comments