在此,关键概念有一个独特的领域,如数据库中你伪造、姓名、用户名和密码的栏目,在数据库表上对以下两种方式进行了研究:
1,使用超链接
<?php
mysql_connect("fostname","username","password");
mysql_select_db("database_name");
$q = mysql_query("SELECT * FROM tbl_name");
if(mysql_num_rows($q)>0)
{
echo"<table>";
echo "<tr><td>name</td><td>action</td></tr>";
while($name = mysql_fetch_assoc($q))
{
?>
<tr><td><?php echo $name[ name ];?></td><td><a href="删除.php?id=<?php echo $name[ id ];?>">Delete</a></td></tr>
<?php
}
echo "</table>";
}
?>
这正是你在列出第...页时所做的。 需要在超文本链接中界定的道路上运行的
删除.php
<?php
mysql_connect("fostname","username","password");
mysql_select_db("database_name");
$id = $_GET[ id ];
$q = mysql_query("delete from tbl_name where id = $id ");
header("Location: list.php");
?>
<>2>。
<?php
mysql_connect("fostname","username","password");
mysql_select_db("database_name");
$q = mysql_query("SELECT * FROM tbl_name");
if(mysql_num_rows($q)>0)
{
echo"<table>";
echo "<tr><td>name</td><td>action</td></tr>";
while($name = mysql_fetch_assoc($q))
{
?>
<tr><td><?php echo $name[ name ];?></td><td><form action= 删除.php method= post > <input type= hidden value= <?php echo $name["id"];?> ></form></td></tr>
<?php
}
echo "</table>";
}
?>
删除.php
<?php
mysql_connect("fostname","username","password");
mysql_select_db("database_name");
$id = $_POSTs[ id ];
$q = mysql_query("delete from tbl_name where id = $id ");
header("Location: list.php");
?>
(注:清单)。 页: 1