PHP MySQL DELETE. Free online PHP and MySQL Web Database Programming Tutorial...
|Lessons||PHP MySQL DELETE|
DELETE FROM table_name
WHERE some_column = some_value
Notice the use of WHERE clause in the DELETE syntax above. The WHERE clause specifies which record or records should be deleted. If you omit the WHERE clause, all records from the table would be deleted!
Just like other SQL statements / commands, we need to use the PHP function mysql_query() to execute the above statement. Let's see an example:
Considerr the following "Students" table:
$con = mysql_connect("localhost", "adam","ada");
die('Error connecting database');
mysql_query("DELETE FROM Students WHERE Name='Jacob'");
Table "Student" after the deletion:
Next: PHP MySQL Where Keyword