level 1
woshidlc
楼主
<?php
$link_id = mysql_connect ( "localhost", "root", "123" ) or die ( "链接失败" );
if ($link_id) {
mysql_select_db ( "aa" );
if ($_GET [id]) {
$result = mysql_query ( "select * from userinfo" );
echo "
<table border = 1>
<tr>
<td>编号</td>
<td>用户</td>
<td>性别</td>
<td>年龄</td>
<td>操作</td>
</tr>";
while ( $row = mysql_fetch_array ( $result ) ) {
echo "<tr>
<td>" . $row [id] . "</td>
<td>" . $row [username] . "</td>
<td>" . $row [gender] . "</td>
<td>" . $row [age] . "</td>
<td><a href=modify.php?id=" . $row [id] . ">编辑</a></td>
</tr>
";
}
echo "</table>";
} else {
if (! $_POST[ok]) {
$sql = "select * from userinfo where id=" . $_GET [id];
$result = mysql_query ( $sql );
$row = mysql_fetch_array ( $result );
?>
<from method=post action='modify.php?id=<?
echo $_GET [id];
?>'>
<?
echo $row [id] . "<br>";
?>
<input type="hidden" name="id" value=<?
echo $row [id];
?>>
姓名
<input type=text name="username"
value=<?
echo $row [username];
?>>
性别
<input type=text name="username" value=<?
echo $row [gender];
?>>
年龄
<input type=text name="username" value=<?
echo $row [age];
?>>
<input type=submit name=ok value="提交">
<?
} else {
$sql = "update userinfo set username='" . $row [username] . "',gender='" .
$row [gender] . "',age='" . $row [age] . "' where id='" . $_POST [id] . "'";
$result = mysql_query($sql);
if ($result)
echo "记录已经成功修改<br><a href='modify.php'>继续修改</a>";
else
echo "记录修改失败<br><a href='modify.php?=".$_POST[id]."'>返回</a>";
}
}
}
?>
2009年07月16日 12点07分
1
$link_id = mysql_connect ( "localhost", "root", "123" ) or die ( "链接失败" );
if ($link_id) {
mysql_select_db ( "aa" );
if ($_GET [id]) {
$result = mysql_query ( "select * from userinfo" );
echo "
<table border = 1>
<tr>
<td>编号</td>
<td>用户</td>
<td>性别</td>
<td>年龄</td>
<td>操作</td>
</tr>";
while ( $row = mysql_fetch_array ( $result ) ) {
echo "<tr>
<td>" . $row [id] . "</td>
<td>" . $row [username] . "</td>
<td>" . $row [gender] . "</td>
<td>" . $row [age] . "</td>
<td><a href=modify.php?id=" . $row [id] . ">编辑</a></td>
</tr>
";
}
echo "</table>";
} else {
if (! $_POST[ok]) {
$sql = "select * from userinfo where id=" . $_GET [id];
$result = mysql_query ( $sql );
$row = mysql_fetch_array ( $result );
?>
<from method=post action='modify.php?id=<?
echo $_GET [id];
?>'>
<?
echo $row [id] . "<br>";
?>
<input type="hidden" name="id" value=<?
echo $row [id];
?>>
姓名
<input type=text name="username"
value=<?
echo $row [username];
?>>
性别
<input type=text name="username" value=<?
echo $row [gender];
?>>
年龄
<input type=text name="username" value=<?
echo $row [age];
?>>
<input type=submit name=ok value="提交">
<?
} else {
$sql = "update userinfo set username='" . $row [username] . "',gender='" .
$row [gender] . "',age='" . $row [age] . "' where id='" . $_POST [id] . "'";
$result = mysql_query($sql);
if ($result)
echo "记录已经成功修改<br><a href='modify.php'>继续修改</a>";
else
echo "记录修改失败<br><a href='modify.php?=".$_POST[id]."'>返回</a>";
}
}
}
?>