<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>查询数据</title>
</head>
<body bgcolor="#00CCFF" text="#000000" link="#000000" vlink="#000000" alink="#000000">
<?php
$db = mysql_connect("localhost", "dick2514","1980216");
mysql_select_db("dick2514");
if ($id) {
 if ($submit) {
$sql = "UPDATE employees SET first='$first',last='$last',
     address='$address',position='$position' WHERE id=$id";
 $result = mysql_query($sql);
 echo "谢谢!数据更改完成\n";
} else {
 $sql = "SELECT * FROM employees WHERE id=$id";
$result = mysql_query($sql); 
$myrow = mysql_fetch_array($result);
 ?>
<form method="post" action="<?php echo $PATH_INFO?>">
<input type=hidden name="id" value="<?php echo $myrow["id"] ?>">
<table border=0>
      <tr><td>名:</td><td><input type=text name=first value="<?php echo  $myrow["first"] ?>" maxlength=13 size=13><br></td></tr>
      <tr><td>姓:</td><td><input type=text name=last value="<?php echo  $myrow["last"] ?>" maxlength=13 size=13><br></td></tr>
      <tr><td>地址:</td><td><input type=text name=address value="<?php echo  $myrow["address"] ?>" maxlength=13 size=13><br></td></tr>
  <tr><td>职位:</td><td><input type=text name=position value="<?php echo  $myrow["position"] ?>" maxlength=13 size=13><br></td></tr>
 <tr><td><input type="Submit" name="submit" value="输入信息"></td></tr>
</table> 
</form>
<?php
}

else {
$result = mysql_query("SELECT * FROM employees");
while ($myrow = mysql_fetch_array($result)) {
printf("<a href=\"%s?id=%s\">%s %s</a>\n", $PATH_INFO, 
     $myrow["id"], $myrow["first"], $myrow["last"]);
}
}
?>
</body>
</html>
这是编辑数据,数据库自己要建,删除也是一个道理。很好实现的。