如何用PHP写一段删除数据库表中的一条记录?急求啊 5
我写的PHP删除代码:<?php$con=mysql_connect("localhost","root","root");if(!$con){die('Couldnot...
我写的PHP删除代码:
<?php
$con = mysql_connect("localhost","root","root");
if (!$con)
{ die('Could not connect: ' . mysql_error()); } mysql_select_db("xinxi", $con);
$result = mysql_query(" SELECT * FROM student WHERE Name=$_POST[refer]");
echo "<table border='1'> <tr>
<th>Name</th>
<th>Sex</th>
<th>Number</th>
<th>Yuanxi</th>
<th>Id</th>
<th>Zz</th>
<th>Hk</th>
<th>Time</th>
<th>Time1</th>
<th>Way</th>
<th>Js</th>
</tr>";
while($row = mysql_fetch_array($result))
{ echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['sex'] . "</td>";
echo "<td>" . $row['yuanxi'] . "</td>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['zz'] . "</td>";
echo "<td>" . $row['hk'] . "</td>";
echo "<td>" . $row['time'] . "</td>";
echo "<td>" . $row['time1'] . "</td>";
echo "<td>" . $row['way'] . "</td>";
echo "<td>" . $row['js'] . "</td>";
echo "</tr>"; }
echo "</table>";
mysql_close($con);
?>
就是在点击删除按钮以后没有报错 但是数据库中的代码并没有少 展开
<?php
$con = mysql_connect("localhost","root","root");
if (!$con)
{ die('Could not connect: ' . mysql_error()); } mysql_select_db("xinxi", $con);
$result = mysql_query(" SELECT * FROM student WHERE Name=$_POST[refer]");
echo "<table border='1'> <tr>
<th>Name</th>
<th>Sex</th>
<th>Number</th>
<th>Yuanxi</th>
<th>Id</th>
<th>Zz</th>
<th>Hk</th>
<th>Time</th>
<th>Time1</th>
<th>Way</th>
<th>Js</th>
</tr>";
while($row = mysql_fetch_array($result))
{ echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['sex'] . "</td>";
echo "<td>" . $row['yuanxi'] . "</td>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['zz'] . "</td>";
echo "<td>" . $row['hk'] . "</td>";
echo "<td>" . $row['time'] . "</td>";
echo "<td>" . $row['time1'] . "</td>";
echo "<td>" . $row['way'] . "</td>";
echo "<td>" . $row['js'] . "</td>";
echo "</tr>"; }
echo "</table>";
mysql_close($con);
?>
就是在点击删除按钮以后没有报错 但是数据库中的代码并没有少 展开
展开全部
$result = mysql_query(" SELECT * FROM student WHERE Name=$_POST[refer]");
这个是显示,从表中读取相关记录的语句。
改成这样的:
$result = mysql_query(" DELETE FROM student WHERE Name=$_POST[refer]");
再试试。
这个是显示,从表中读取相关记录的语句。
改成这样的:
$result = mysql_query(" DELETE FROM student WHERE Name=$_POST[refer]");
再试试。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
亲,我怎么没有看到删除的sql语句呢!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询