修改小程序


<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>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值