<!--deletelist.php-->
<html>
<head>
<title>删除数据</title>
</head>
<body bgcolor="yellow">
<br><center><b>删除数据</b></center><br><br><hr><br>
<?
$cn=@mysql_connect('localhost','root','666666');
$strSQL1="select * from test1 order by Sno ASC";
$result1=mysql_db_query("testdb",$strSQL1,$cn);
$total=mysql_num_rows($result1);
echo"<table align='center' border=1>";
echo"<tr><th>删除</th><th>学号</th><th>姓名</th><th>性别</th><th>个人说明</th></tr>";
while($arr=mysql_fetch_array($result1))
{
echo"<tr><td><a href='delete.php?Sno=$arr[Sno]'>删除</a></td>";
printf("<td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>",
$arr[Sno],$arr[Name],$arr[Sex],$arr[Hobby]);
echo"</tr>";
}
echo"</table>";
echo"<br><hr><center>当前资料数:".$total."</center>";
mysql_close($cn);
?>
</body>
</html>
-----------------------------------------------------------
<!--delete.php-->
<html>
<body>
<?
$cn=@mysql_connect('localhost','root','666666');
$strSQL="delete from test1 where Sno='".(int)($Sno)."'";
$result=mysql_db_query("testdb",$strSQL,$cn);
echo "$Sno";
mysql_close($cn);
?>
</body>
</html>变量似乎没有接受到,是不是接收变量的写法“$Sno”有误,有别的更好的写法吗?
<html>
<head>
<title>删除数据</title>
</head>
<body bgcolor="yellow">
<br><center><b>删除数据</b></center><br><br><hr><br>
<?
$cn=@mysql_connect('localhost','root','666666');
$strSQL1="select * from test1 order by Sno ASC";
$result1=mysql_db_query("testdb",$strSQL1,$cn);
$total=mysql_num_rows($result1);
echo"<table align='center' border=1>";
echo"<tr><th>删除</th><th>学号</th><th>姓名</th><th>性别</th><th>个人说明</th></tr>";
while($arr=mysql_fetch_array($result1))
{
echo"<tr><td><a href='delete.php?Sno=$arr[Sno]'>删除</a></td>";
printf("<td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>",
$arr[Sno],$arr[Name],$arr[Sex],$arr[Hobby]);
echo"</tr>";
}
echo"</table>";
echo"<br><hr><center>当前资料数:".$total."</center>";
mysql_close($cn);
?>
</body>
</html>
-----------------------------------------------------------
<!--delete.php-->
<html>
<body>
<?
$cn=@mysql_connect('localhost','root','666666');
$strSQL="delete from test1 where Sno='".(int)($Sno)."'";
$result=mysql_db_query("testdb",$strSQL,$cn);
echo "$Sno";
mysql_close($cn);
?>
</body>
</html>变量似乎没有接受到,是不是接收变量的写法“$Sno”有误,有别的更好的写法吗?
// (1) Open the database connection and use the database
$connection = mysql_connect("localhost",$username,$password); mysql_select_db("databaseName", $connection); // (2) Run the query on the database through the
// connection
$result = mysql_query ("SELECT * FROM tableName", $connection); ....... // (5) Close the database connection
mysql_close($connection);
?>