如何从数据库中删除

时间:2015-09-23 14:07:20

标签: php mysql database

好的,我的代码,我可以通过按提交按钮更新编辑的记录,并使用此

$action =(isset($_POST['submit']) ? $_POST['submit'] : null);
if($action!=null) {                 
    $id =(isset($_POST['id']) ? $_POST['id'] : null);

    $query="update club set adminApprove='Y' where id=$id";
    $result=mysql_query($query);

    echo "<br><p style='text-align:center;color:blue'>Club record has been updated</p>";

    echo mysql_error(); 

那么如何创建这样的东西来从数据库中删除呢?谢谢

3 个答案:

答案 0 :(得分:0)

$query = "DELETE FROM club WHERE id = $id";
$result = mysql_query($query);

echo "<br><p style='text-align:center;color:blue'>Club record has been DELETED!</p>";

答案 1 :(得分:0)

DELETE FROM table_name
WHERE some_column = some_value 

http://www.w3schools.com/php/php_mysql_delete.asp

答案 2 :(得分:0)

$query = "DELETE FROM table_name WHERE id=$id";
$result=mysql_query($query);