我想在PHP代码中选择一个数据,并且选择的数据是从一个mysql数据库中呈现出来的,那么选择的数据就会被删除!这是我的总体想法。
我写了代码,第一个代码是打印数据库中的数据让用户选择数据,这是第一个代码:
<form method="POST" action="deleteacc.php" name='monitor' id='monitor'>
<select name="drivers"><option>Please Select the sensor id that you want to delete :</option>
<?php
$uid=$_SESSION['uid'];
$dbName = "senior"; //Database name
$db = mysql_connect ("localhost","root","hahaha1") or die("Unable To Connect "); //Connect to database
$test= mysql_select_db ($dbName,$db) or die("Unable to select database"); //Test Connection
$result=mysql_query("SELECT * FROM accelerometer ");
while ($row=mysql_fetch_array($result))
{
$sid = $row['sid'];
$x=$row['x'];
$y=$row['y'];
$z=$row['z'];
$date=$row['date'];
$time=$row['time'];
echo "<option name=$sid' value='$sid'> Device ID: $sid</option>";
}
mysql_close($db);
?>
</select></center>
<br>
<center> <input type="submit" value= " Monitor " name="submit" ><br /><br /> </center>
</form>
我删除所选数据的第二个代码:
<?php
$dbh=mysql_connect("localhost", "root", "hahaha1") or die (mysql_error());
mysql_select_db ("senior");
extract($_POST);
$mySql="DELETE FROM accelerometer WHERE sid=$drivers";
mysql_query($mySql) or die (mysql_error());
echo "<h2> User info was deleted successfully</h2>";
echo "<h3>To go back to adminstration control click <a href='member.php'>Here!</a> or to delete another accelerometer value click <a href='deleteacc2.php'>Here!</a></h3>";
mysql_close($dbh);
?>
我的问题是当我从菜单中选择数据并按下监视器时,这个错误显示给我:
Unknown column 'bedoor' in 'where clause'
请对如何解决我的问题有任何想法吗?