php 中怎么实现点击按钮 然后从MYSQL中删除对应行的数据..希望高手教我
<tablewidth="600"border="1"><tr><tdwidth="300"><?echo$myrow["name"]?></td><tdwidth="3...
<table width="600" border="1">
<tr>
<td width="300"><? echo $myrow["name"] ?></td>
<td width="300"><? echo $myrow["sex"] ?></td>
<td width="300"><? echo $myrow["age"] ?></td>
<td width="300"><? echo $myrow["address"] ?></td>
<td width="300"><a href="xiugai.php">修改信息</a></td>
<td width="300"><input type="submit" name="Submit" value="删除" /> </td>
</tr>
</table>
include("conn.php");
if(!empty($_POST['Submit'])){
$name=$_POST['name'];
$sql="delete from student where name='$name'";
$query=mysql_query($sql);
if($query){
echo "<script>alert('删除成功');
history.back();</script>";
代码哪里有问题?麻烦解释下~~
我就想要点击删除按钮然后把那一条都给删掉~~
求大神指教~~ 展开
<tr>
<td width="300"><? echo $myrow["name"] ?></td>
<td width="300"><? echo $myrow["sex"] ?></td>
<td width="300"><? echo $myrow["age"] ?></td>
<td width="300"><? echo $myrow["address"] ?></td>
<td width="300"><a href="xiugai.php">修改信息</a></td>
<td width="300"><input type="submit" name="Submit" value="删除" /> </td>
</tr>
</table>
include("conn.php");
if(!empty($_POST['Submit'])){
$name=$_POST['name'];
$sql="delete from student where name='$name'";
$query=mysql_query($sql);
if($query){
echo "<script>alert('删除成功');
history.back();</script>";
代码哪里有问题?麻烦解释下~~
我就想要点击删除按钮然后把那一条都给删掉~~
求大神指教~~ 展开
1个回答
2012-07-10
展开全部
<form name="subscription" action="这个是你PHP文件的路径" method="post">
<input type="hidden" name="id" value="<?php echo $myrow["id"] ?>"/>
<table width="600" border="1">
<tr>
<td width="300"><?php echo $myrow["name"] ?></td>
<td width="300"><?php echo $myrow["sex"] ?></td>
<td width="300"><?php echo $myrow["age"] ?></td>
<td width="300"><?php echo $myrow["address"] ?></td>
<td width="300"><a href="xiugai.php">修改信息</a></td>
<td width="300"><input type="submit" name="Submit" value="删除" /> </td>
</tr>
</table>
</form>
<?php
include("conn.php");
if(!empty($_POST)){
$id = $_POST['id'];
$sql = "delete from student where id='$id'";
$query = mysql_query($sql);
if($query){
echo "<script>alert('删除成功');history.back();</script>";
}
}
?>
<input type="hidden" name="id" value="<?php echo $myrow["id"] ?>"/>
<table width="600" border="1">
<tr>
<td width="300"><?php echo $myrow["name"] ?></td>
<td width="300"><?php echo $myrow["sex"] ?></td>
<td width="300"><?php echo $myrow["age"] ?></td>
<td width="300"><?php echo $myrow["address"] ?></td>
<td width="300"><a href="xiugai.php">修改信息</a></td>
<td width="300"><input type="submit" name="Submit" value="删除" /> </td>
</tr>
</table>
</form>
<?php
include("conn.php");
if(!empty($_POST)){
$id = $_POST['id'];
$sql = "delete from student where id='$id'";
$query = mysql_query($sql);
if($query){
echo "<script>alert('删除成功');history.back();</script>";
}
}
?>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询