再会!我的删除按钮一直有问题。我在一页中有 3 个表单,这两个表单提交只是让我的删除 mo 不起作用。我认为问题出在isset上,但我不知道如何解决。请帮忙。
这是代码:
<h3>Delete Card</h3>
<div class="formdel">
<form action="" method="post" id="formdel" name="formdel">
<div class="control-group">
<label class="control-label" for="cnum">Card Type Name</label>
<div class="controls">
<select name = "cnum" id = "cnum" style="width: 250px;">
<option value = "NONE" disabled selected>Card Type Name</option>
<?php
$querya = "SELECT CardTypeID, CardTypeName FROM cardtype";
$resulta = mysql_query($querya);
while($rowmem = mysql_fetch_array($resulta)){
echo "<option value = ". $rowmem['CardTypeID'] .">" . $rowmem['CardTypeName'] . " </option>";
}
?>
</select>
</div>
</div>
<button type='submit' class='btn btn-large btn-danger' name="delete1" id="delete1" style="margin-left:90px; margin-top: 20px;">Delete</button>
<?php
if (isset($_POST['delete1'])){
$canum = $_POST['cnum'];
$querydel = mysql_query("DELETE FROM CardType WHERE CardTypeID = $canum",$connect);
if ($querydel){
echo "<div class='alert alert-success' style='font-size: 12px; width: 300px;'>
<a class='close' data-dismiss='alert'>×</a>
<center>Delete successful!</center></div>";
}
else {
echo "<div class='alert alert-success' style='font-size: 12px; width: 300px;'>
<a class='close' data-dismiss='alert'>×</a>
<center>Delete unsuccessful!</center></div>";
}
}
?>