首页上一页 1 下一页尾页 2 条记录 1/1页
急!!!数据无法给新
发表在PHP图书答疑
2010-10-14
是否精华
是
否
版块置顶:
是
否
《PHP程序开发范例宝典》第6章实例148有问题,查询信息能正常显示,但点击更新按钮没法更新,几等解决方法,本人QQ:240515190,在线等
index.php文件内容如下:
<?php session_start(); include("conn/conn.php");?>
<html>
<head>
<title>单条数据更新</title>
</head>
<body>
<table width="535" height="264" border="0" cellpadding="0" cellspacing="0" background="images/bg.jpg">
<tr>
<td width="55" height="106"> </td>
<td width="325"> </td>
<td width="55"> </td>
</tr>
<tr>
<td height="125"> </td>
<td align="left" valign="top"><table width="425" border="1" cellpadding="0" cellspacing="0">
<tr>
<td width="60" height="25" align="center" class="STYLE1">ServerName</td>
<td width="60" align="center" class="STYLE1">IP</td>
<td width="80" align="center" class="STYLE1">Status</td>
<td width="145" align="center"><span class="STYLE1">Date</span></td>
<td width="80" align="center"></td>
</tr>
<?php $query=mysql_query("select * from test");
if($query==true){
while($myrow=mysql_fetch_array($query)){
$sid=$myrow[ID];
?>
<?php echo $lmbs;?>
<form name="form1" method="post" action="index_ok.php?lmbs=<?php echo $sid;?>">
<tr>
<td height="25" align="center" class="STYLE1"><label>
<input name="ServerName" type="text" id="ServerName" value="<?php echo $myrow[ServerName];?>" size="6">
</label></td>
<td align="center" class="STYLE1"><input name="IP" type="text" id="IP" value="<?php echo $myrow[IP];?>" size="6"></td>
<td align="center" class="STYLE1"><input name="Status" type="text" id="Status" value="<?php echo $myrow[Status];?>" size="9"></td>
<td align="center" class="STYLE1"><input name="Date" type="text" id="Date" value="<?php echo $myrow[Date];?>" size="18"></td>
<td align="center"><input type="image" name="imageField" src="images/bg1.jpg"></td>
</tr>
</form>
<?php }}?>
</table>
</td>
<td> </td>
</tr>
<tr>
<td height="33"> </td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
index_ok.php文件内容如下:
<?php session_start(); include("conn/conn.php");?>
<?php
if($lmbs==true)
{
$sid=$_POST[sid];
$query=mysql_query("update test set ServerName='$_POST[ServerName]',IP='$_POST[IP]',Status='$_POST[Status]',Date='$_POST[Date]' where ID='$lmbs'");
}
if($query==true)
{
echo "<script>alert('员工资料更新成功!!');window.location.href='./index.php';</script>";
}
else
{
echo $query;
echo "更新失败:". mysql_error();
}
?>
index.php文件内容如下:
<?php session_start(); include("conn/conn.php");?>
<html>
<head>
<title>单条数据更新</title>
</head>
<body>
<table width="535" height="264" border="0" cellpadding="0" cellspacing="0" background="images/bg.jpg">
<tr>
<td width="55" height="106"> </td>
<td width="325"> </td>
<td width="55"> </td>
</tr>
<tr>
<td height="125"> </td>
<td align="left" valign="top"><table width="425" border="1" cellpadding="0" cellspacing="0">
<tr>
<td width="60" height="25" align="center" class="STYLE1">ServerName</td>
<td width="60" align="center" class="STYLE1">IP</td>
<td width="80" align="center" class="STYLE1">Status</td>
<td width="145" align="center"><span class="STYLE1">Date</span></td>
<td width="80" align="center"></td>
</tr>
<?php $query=mysql_query("select * from test");
if($query==true){
while($myrow=mysql_fetch_array($query)){
$sid=$myrow[ID];
?>
<?php echo $lmbs;?>
<form name="form1" method="post" action="index_ok.php?lmbs=<?php echo $sid;?>">
<tr>
<td height="25" align="center" class="STYLE1"><label>
<input name="ServerName" type="text" id="ServerName" value="<?php echo $myrow[ServerName];?>" size="6">
</label></td>
<td align="center" class="STYLE1"><input name="IP" type="text" id="IP" value="<?php echo $myrow[IP];?>" size="6"></td>
<td align="center" class="STYLE1"><input name="Status" type="text" id="Status" value="<?php echo $myrow[Status];?>" size="9"></td>
<td align="center" class="STYLE1"><input name="Date" type="text" id="Date" value="<?php echo $myrow[Date];?>" size="18"></td>
<td align="center"><input type="image" name="imageField" src="images/bg1.jpg"></td>
</tr>
</form>
<?php }}?>
</table>
</td>
<td> </td>
</tr>
<tr>
<td height="33"> </td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
index_ok.php文件内容如下:
<?php session_start(); include("conn/conn.php");?>
<?php
if($lmbs==true)
{
$sid=$_POST[sid];
$query=mysql_query("update test set ServerName='$_POST[ServerName]',IP='$_POST[IP]',Status='$_POST[Status]',Date='$_POST[Date]' where ID='$lmbs'");
}
if($query==true)
{
echo "<script>alert('员工资料更新成功!!');window.location.href='./index.php';</script>";
}
else
{
echo $query;
echo "更新失败:". mysql_error();
}
?>