![]() |
|
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: Example Considerr the following "Students" table:
<?php $con = mysql_connect("localhost", "adam","ada"); if (!$con) { die('Error connecting database'); } mysql_select_db("my_db", $con); mysql_query("DELETE FROM Students WHERE Name='Jacob'"); mysql_close($con); ?> Table "Student" after the deletion:
Next: PHP MySQL Where Keyword
|