<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>编辑数据库</title>
</head><body>
<?php
$conn = mysql_connect('localhost','root','root')or die("connect err:".mysql_error());
mysql_query("use tongxuhua");
//mysql_select_db("tongxuhua");
//mysql_query("set name gb2312");
$table=mysql_query("select * from tb_mrbook",$conn);
echo '<form name="bookname" method="post" action="chapter15-2">';
echo "<table border=1><tr>";
while($field=mysql_fetch_field($table)){
echo "<td> ".$field->name." </td>";
}
echo "</tr>";
while($row=mysql_fetch_row($table)){
echo "<tr>";
for($i=0;$i<count($row);$i++)
echo "<td>".$row[$i]."</td>";
echo "<td><a href=? action=modify&id=".$row[$i].">修改</a>/<a href=?action=del&id=".$row[$i].">删除</a></td>";
echo "</tr>";
}
echo "</td></table>";
echo "</form>";
?>
<?php //删除数据
if($_POST[action]=="del"){
$conn=mysql_connect("localhost","root","root");
mysql_query("set names gb2312");
mysql_query("use tongxuhua");
$sqlstr="delete form tb_mrbook where id=".$_GET[id];
$result=mysql_query($sqlstr,$conn);
if($result){
echo "<script>alert('删除成功')</script>";
}
else echo "<script>alert('删除失败')</script>";
}?>
</body>
</html>为什么我按删除没反映啊
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>编辑数据库</title>
</head><body>
<?php
$conn = mysql_connect('localhost','root','root')or die("connect err:".mysql_error());
mysql_query("use tongxuhua");
//mysql_select_db("tongxuhua");
//mysql_query("set name gb2312");
$table=mysql_query("select * from tb_mrbook",$conn);
echo '<form name="bookname" method="post" action="chapter15-2">';
echo "<table border=1><tr>";
while($field=mysql_fetch_field($table)){
echo "<td> ".$field->name." </td>";
}
echo "</tr>";
while($row=mysql_fetch_row($table)){
echo "<tr>";
for($i=0;$i<count($row);$i++)
echo "<td>".$row[$i]."</td>";
echo "<td><a href=? action=modify&id=".$row[$i].">修改</a>/<a href=?action=del&id=".$row[$i].">删除</a></td>";
echo "</tr>";
}
echo "</td></table>";
echo "</form>";
?>
<?php //删除数据
if($_POST[action]=="del"){
$conn=mysql_connect("localhost","root","root");
mysql_query("set names gb2312");
mysql_query("use tongxuhua");
$sqlstr="delete form tb_mrbook where id=".$_GET[id];
$result=mysql_query($sqlstr,$conn);
if($result){
echo "<script>alert('删除成功')</script>";
}
else echo "<script>alert('删除失败')</script>";
}?>
</body>
</html>为什么我按删除没反映啊
改为: if($_GET[action]=="del"){
改为: if($_GET['action']=="del"){
拜托 from写成form 又是这种低级错误!