我想从 MySQL 数据库中删除一行,但我无法执行此操作,尽管我可以更新该行。第一部分是更新代码,第二部分是删除代码。
有趣的是,它向我显示了成功删除的警报,但实际上在 MySQL 数据库中没有任何改变。
<?php
// for updating Check if button name "Submit" is active, do this
if(isset($_POST['Submit']) && $_POST['Submit'] == 'update')
{
$sql1=mysql_query(" UPDATE `".$tbl_name."` SET `username`='".$_REQUEST['user']."' , `password`='".$_REQUEST['pass']."' , `name`='".$_REQUEST['name']."' , `lastname`='".$_REQUEST['lastname']."' , `phone`='".$_REQUEST['phone']."' , `state`='".$_REQUEST['state']."' , `details`='".$_REQUEST['details']."' WHERE `id`='".$_REQUEST['id']."' ");
$result1=mysql_query($sql1);
}
if(isset($result1)){
?>
<script language="javascript">alert('successfuly updated');</script>
<?php
print(redirect('editteacher.php'));
}
mysql_close();
?>
<?php
//for deleting Check if button name "Submit" is active, do this
if(isset($_POST['delete']) && $_POST['delete'] == 'delete user')
{
$sql1=" DELETE FROM `".$tbl_name."` WHERE `username`='789' ";
$result1=mysql_query($sql1);
if(isset($result1)){
?>
<script language="javascript">alert('successfuly deleted');</script>
<?php
print(redirect('editteacher.php'));
}
}
mysql_close();
?>