|
|
发表于 16-10-2009 11:36 AM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 17-10-2009 07:13 AM
|
显示全部楼层
又有问题了,我的edit这一面好像query不到database的东西出来,请问有什么问题吗?
另外,如果我要做multiple UPDATE的话,可以这样做吗?请各位大大教教我。。。 
$id1 = $_POST["id1"];
$an1 = $_POST["an1"];
$id2 = $_POST["id2"];
$an2 = $_POST["an2"];
$id3 = $_POST["id3"];
$an3 = $_POST["an3"];
$sql = "UPDATE association SET AssociationName = '$an1''$an2''$an3', ID = '$'id1' '$'id2' '$'id3'";
这是我的coding。
|
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 17-10-2009 07:17 AM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|
发表于 17-10-2009 02:30 PM
|
显示全部楼层
用 UPDATE , SET , WHERE CONDITION IN ( Criteria )  |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 17-10-2009 09:06 PM
|
显示全部楼层
那个问题解决了,现在我query不到database所有的的东西,只能query到一个而已.我的database只有Index和Name,我的Name都是不同的,可是Index有些是相同的,所以我想问下有没有方法query database里的所有东西,然后让user去选择他要edit他要edit的东西? 或者有什么好建议吗?
比如说, 我的database里面有aaa, bbb, ccc, ddd; 可是我只能query到aaa来edit罢了,请问要解决呢?
<html>
<head>
<title>Index</title>
</head>
<div style="position: absolute; width: 1146px; height: 842px; z-index: 1; left:10px; top:1px" id="layer2" align="center">
<body background="E-Filing%20Management%20System%20Picture/Snow.gif">
<p align="center">
<img border="0" src="E-Filing%20Management%20System%20Picture/logo-RR-gif.gif" width="957" height="245"></p>
<p align="center"><span lang="zh-cn"> </span></p>
<p align="center"><span lang="zh-cn"><img border="0" src="E-Filing%20Management%20System%20Picture/Association.gif" width="491" height="74"></span></p>
<p align="center"><span lang="zh-cn"> </span></p>
<form method="post" action="AssociationEdit.php">
<?php
$connection = mysql_connect("localhost", "root", "")
or die("<font color='#FFFFFF'>Could not connect to MySQL </font>" .mysql_error() );
$selection = mysql_select_db("efiling")
or die("<font color='#FFFFFF'>Unable to select database. </font>" .mysql_error());
$sql = "SELECT * from association Where AssociationName LIKE 'A%' OR AssociationName LIKE 'B%' ORDER BY AssociationName";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
echo "<div style='position: absolute; width: 214px; height: 28px; z-index: 2; left: 521px; top: 441px' id='layer4'><font color='#FFFFFF'><span lang='en-us'><font size='4' face='Arial Rounded MT Bold'> Association Name</font></span></font></div>";
echo "<div style='position: absolute; width: 70px; height: 24px; z-index: 1; left: 285px; top: 442px' id='layer3'><font size='4' face='Arial Rounded MT Bold'><font color='#FFFFFF'><span lang='en-us'>Index</span></font></font></div>";
echo "<br><p align='center'><input type='text' name='id1' value='$row[ID]' size='11'>";
echo " <input type='text' name='an1' value='$row[AssociationName]' size='77'></p><br>";
echo "<input type='submit' name='submit' value='Update'> ";
echo "<input type='submit' name='submit' value='Back'>";
if(isset($_POST["submit"]))
{
$submit = $_POST["submit"];
$id1 = $_POST["id1"];
$an1 = $_POST["an1"];
if($submit=="Update")
{
$sql2 = "SELECT * from association Where AssociationName='$an1'";
$result2 = mysql_query($sql2)
or die("<font color='#FFFFFF'>SQL select statement failed</font>");
if (mysql_num_rows($result2) < 1)
{
$id1 = $_POST["id1"];
$an1 = $_POST["an1"];
$sql = "UPDATE association SET AssociationName = '$an1', ID = '$id1' WHERE AssociationName='$an1'";
$result2 = mysql_query($sql);
echo "<hr><h2><font color='#FFFFFF'>Record Updated</font></h2>";
}
else
{
print"<p align='center'> </p>
<table width='400' height='200' border='1' align='center' bordercolor='#66FF00'bgcolor='#0000FF'>
<td><div align='center'><font color='#FF0000' size='5'><p>The Association Name Has Been Registered, Please Enter Other Association Name</p> </font></div></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table> ";
print "<p align='center'> </p>";
echo "<HTML><META HTTP-EQUIV='REFRESH' CONTENT='2; URL=Association.php'>
<CENTER><p> </p><p>
<tr>
<td align='center'><h12>please wait...</h12></td>
</tr>
</table><p> </p><p> </p></CENTER></BODY></HTML>";
}
}
if($submit=="Back")
{
print "<script language ='javascript'>window.location.href='Association.php'</script>";
}
}
?>
</form>
<p align="center"></p>
<p align="center"></p>
<p align="center"></p>
<p align="center"></p>
<p align="center"></p>
</div>
</body>
</html>
[ 本帖最后由 NgSzeyin2005 于 17-10-2009 11:08 PM 编辑 ] |
|
|
|
|
|
|
|
|
|
|
发表于 18-10-2009 02:19 PM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 19-10-2009 06:42 PM
|
显示全部楼层
原帖由 vampcheah 于 18-10-2009 02:19 PM 发表 
网站scrolling 的问题是因为 html 布局。
有些是因为 div, 有些是width % 或 fixed width, 有些是 css。
很难告诉你原因出在哪里,要把整个网站的 html code 看过才知道。
database 的结构很重要,必须使用 ...
我已经加入Primary Key了,这是我的coding。当我按Update时,“Record Updated”有出现,可是database里却没改到,当我去database看回去时,那个data还是之前那个。请问要怎样解决呢?谢谢。。。
<html>
<head>
<title>Index</title>
</head>
<div style="position: absolute; width: 1146px; height: 842px; z-index: 1; left:10px; top:1px" id="layer2" align="center">
<body background="E-Filing%20Management%20System%20Picture/Snow.gif">
<p align="center">
<img border="0" src="E-Filing%20Management%20System%20Picture/logo-RR-gif.gif" width="957" height="245"></p>
<p align="center"><span lang="zh-cn"> </span></p>
<p align="center"><span lang="zh-cn"><img border="0" src="E-Filing%20Management%20System%20Picture/Association.gif" width="491" height="74"></span></p>
<p align="center"><span lang="zh-cn"> </span></p>
<form method="post" action="AssociationEdit.php">
<?php
$connection = mysql_connect("localhost", "root", "")
or die("<font color='#FFFFFF'>Could not connect to MySQL </font>" .mysql_error() );
$selection = mysql_select_db("efiling")
or die("<font color='#FFFFFF'>Unable to select database. </font>" .mysql_error());
echo "<font size='3' face='Arial Rounded MT Bold'><font color='#FFFFFF'>Please insert Primary Key : </font></font>";
echo"<input type='text' name='PK' size='6'>";
echo " <input type='submit' name='submit' value='Search'>";
if(isset($_POST["submit"]))
{
$submit = $_POST["submit"];
$PK = $_POST["PK"];
if($submit=="Search")
{
$PK = $_POST["PK"];
$sql = "SELECT * FROM association where PriKey = '$PK'";
$result = mysql_query($sql)
or die("<font color='#FFFFFF'>SQL select statement failed</font>");
if($row = mysql_fetch_array($result))
{
echo "<p><br><br>";
echo "<font size='3' face='Arial Rounded MT Bold'><font color='#FFFFFF'>Index : </font></font><input type='text' name='id' value='$row[ID]' size='11'> ";
echo "<font size='3' face='Arial Rounded MT Bold'><font color='#FFFFFF'> Association Name : </font></font><input type='text' name='an' value='$row[AssociationName]' size='77'> ";
echo "<br><br><br><input type='submit' name='submit' value='Update'> ";
echo "<input type='submit' name='submit' value='Back'>";
}
else
{
print"<p align='center'> </p>
<table width='400' height='200' border='1' align='center' bordercolor='#66FF00'bgcolor='#0000FF'>
<td><div align='center'><font color='#FF0000' size='5'><p>You might enter a wrong Primary Key, please check back.</p> </font></div></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table> ";
print "<p align='center'> </p>";
echo "<HTML><META HTTP-EQUIV='REFRESH' CONTENT='2; URL=AssociationEdit.php'>
<CENTER><p> </p><p>
<tr>
<td align='center'><h12>please wait...</h12></td>
</tr>
</table><p> </p><p> </p></CENTER></BODY></HTML>";
}
}
if($submit=="Update")
{
$PK = $_POST["PK"];
$id = $_POST["id"];
$an = $_POST["an"];
$sql2 = "SELECT * from association Where AssociationName='$an'";
$result2 = mysql_query($sql2)
or die("<font color='#FFFFFF'>SQL select statement failed</font>");
if (mysql_num_rows($result2) <1)
{
$PK = $_POST["PK"];
$id = $_POST["id"];
$an = $_POST["an"];
$sql = "UPDATE association SET ID = '$id', AssociationName = '$an' WHERE PriKey='$PK'";
$result = mysql_query($sql);
echo "<hr><h2><font color='#FFFFFF'>Record Updated</font></h2>";
echo "<br><input type='submit' name='submit' value='Back'>";
}
else
{
print"<p align='center'> </p>
<table width='400' height='200' border='1' align='center' bordercolor='#66FF00'bgcolor='#0000FF'>
<td><div align='center'><font color='#FF0000' size='5'><p>The Association Name Has Been Registered, Please Enter Other Association Name</p> </font></div></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table> ";
print "<p align='center'> </p>";
echo "<HTML><META HTTP-EQUIV='REFRESH' CONTENT='2; URL=AssociationEdit.php'>
<CENTER><p> </p><p>
<tr>
<td align='center'><h12>please wait...</h12></td>
</tr>
</table><p> </p><p> </p></CENTER></BODY></HTML>";
}
}
if($submit=="Back")
{
print "<script language ='javascript'>window.location.href='Association.php'</script>";
}
}
?>
</form>
<p align="center"></p>
<p align="center"></p>
<p align="center"></p>
<p align="center"></p>
<p align="center"></p>
</div>
</body>
</html> |
|
|
|
|
|
|
|
|
|
|
发表于 19-10-2009 07:38 PM
|
显示全部楼层
|
echo update的sql出来看, 看下对不对...看$id或$pk都没有空... |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 19-10-2009 10:53 PM
|
显示全部楼层
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|