<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
$lianjie = mysql_connect("localhost","root","xiaolie") or die("串連失敗");
mysql_query("set names utf8");
if($lianjie)
{
mysql_select_db("xiaolie");
if(!$_GET)
{
$xuanbiao = "select * from zhuce";
$fasong = mysql_query($xuanbiao) or die(mysql_error());
echo "<table border=1>
<tr>
<td>編號</td>
<td>使用者名稱稱</td>
<td>性別</td>
<td>年齡</td>
<td>註冊時間</td>
<td>操作</td>
</tr>";
while($nr=mysql_fetch_array($fasong))
{
echo "<tr>
<td>".$nr["id"]."</td>
<td>".$nr["name"]."</td>
<td>".$nr["xingbie"]."</td>
<td>".$nr["nianling"]."</td>
<td>".$nr["zc_shijian"]."</td>
<td><a href=gx_my.php?id=".$nr["id"].">編輯</a></td>
</tr>";
}
echo "</table>";
}
else
{
if(!$_POST)
{
$xianid = "select * from zhuce where id=".$_GET["id"];
$fasong = mysql_query($xianid) or die(mysql_error());
$nr = mysql_fetch_array($fasong);
?>
<form method=post action="gx_my.php?id=<?php echo $_GET["id"];?>">
<?php
echo $nr["id"]."<br>";
?>
<input type="hidden" name="id" value=<?php echo $nr["id"];?>>
姓名<input type="text" name="name" value=<?php echo $nr["name"];?>><br>
性別<input type="text" name="xingbie" value=<?php echo $nr["xingbie"];?>><br>
年齡<input type="text" name="nianling" value=<?php echo $nr["nianling"];?>><br>
註冊時間<input type="text" name="zc_shijian" value=<?php echo $nr["zc_shijian"];?>><br>
<input type="submit" name="ok" value="提交">
</form>
<?php
}
else
{
$gx = "update zhuce set name='".$_POST["name"]."',xingbie='".$_POST["xingbie"]."',nianling='".$_POST["nianling"]."',zc_shijian='".$_POST["zc_shijian"]."' where id='".$_POST["id"]."'";
$fasong = mysql_query($gx);
if($fasong){
echo "記錄已經成功修改<br><a href=gx_my.php>繼續修改記錄</a>";}
else{
echo "記錄修改失敗<br><a href=gx_my.php?id=".$_POST["id"].">返回</a>"; }
}
}
}