<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Employee information management</title>
</head>
<style>
b{ color:#FFFFFF; font-family:"楷体_gb2312";}
</style>
<body text="#FFFFFF" background="pic/login_bg.jpg" style="font-size:12px; font-family:'楷体_gb2312'">
<table align="center" border="1" bordercolor="#CCCCCC" cellspacing="0"><tr><td width="438">
<img src="pic/bg_02.jpg" width="438" height="50">
</td>
</tr><tr><td height="158"><table><tr><td width="76" height="142" style="border-right:inset; border-right-color:#CCCCCC">
<img src="pic/bg_03.jpg" width="74" height="140">
</td>
<td width="348"><table border="1" bordercolor="#FF0000" cellspacing="0" style="font-size:14px"><tr><td>Name/td><td>Age</td><td>Sex</td><td>Call</td>
<td>Home addresss</td><td>Operation</td>
<?php
$link = mysql_pconnect("localhost", "root", "111");
mysql_select_db("db_database02",$link);
mysql_query("SET NAMES utf8");
$query = "SELECT * FROM tb_for_1";
$result = mysql_query($query);
for ($i = mysql_num_rows($result) - 1; $i >= 0; $i--) {
if (!mysql_data_seek($result, $i)) {
echo "Cannot seek to row $i: " . mysql_error() . "\n";
continue;
}
if(!($row = mysql_fetch_object($result)))
continue;
echo "<tr><td>$row->name</td><td>$row->age</td><td>$row->sex</td><td>$row->tel</td><td>$row->address</td>
<td><a href='index.php?id=$row->id&delete=1'><b>Delete</b></a> <a href='index.php?id=$row->id&update=1'><b>Modify</b></a></td></tr>";
}
mysql_free_result($result);
if($_GET[delete] == 1){
$sql = "delete from tb_for_1 where id = '$_GET[id]'";
if(mysql_query($sql)){
echo "<script>alert('Delete Successfully');location.href='index.php'</script>";
}
}
if($_GET[update] == 1){
$sql = "select * from tb_for_1 where id ='$_GET[id]'";
$rs = mysql_query($sql);
$rst = mysql_fetch_array($rs);
?>
</table><br><br>
<form action="" method="post">
<input name="name" type="text" value="<?php echo $rst[name];?>" size="6">
<input name="age" type="text" value="<?php echo $rst[age];?>" size="6">
<input name="sex" type="text" value="<?php echo $rst[sex];?>" size="6">
<input name="tel" type="text" value="<?php echo $rst[tel];?>" size="11">
<input name="address" type="text" value="<?php echo $rst[address];?>" size="6">
<input type="submit" name="sub1" value="Modify">
</form></td></tr></table></td></tr></table>
<?php
if($_POST[sub1]){
$sql = "update tb_for_1 set name = '$_POST[name]',age = '$_POST[age]',sex = '$_POST[sex]',tel = '$_POST[tel]',address = '$_POST[address]' where id = '$_GET[id]'";
if(mysql_query($sql)){
echo "<script>alert('Modify successfully');location.href='index.php'</script>";
}
}
}
?>
</body>
</html>
修改小程序
最新推荐文章于 2024-05-13 08:13:54 发布