佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

12
返回列表 发新帖
楼主: NgSzeyin2005

[已解决]谢谢大家。。。

[复制链接]
发表于 16-10-2009 11:36 AM | 显示全部楼层
原帖由 超级丑八怪[-_-] 于 8-10-2009 10:25 PM 发表
想要 Sorting,
就直接在 SQL 后面那邊加入那 ORDER BY 的 Code 就可以了。

PS:
可以用SQL做的東西,
就盡量用SQL做。
這會增加效率,
也會減少很多Front End需要付出&開發的時間。


那这样会不会导致mysql的server很忙碌哦?
回复

使用道具 举报


ADVERTISEMENT

 楼主| 发表于 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。
  • <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='4' face='Arial Rounded MT Bold'><font color='#FFFFFF'><span lang='en-us'>lease select a group : </font></span>";
  • echo"<select name='an'>";
  • echo "<option>---Please Select---</option>";
  • echo "<option value='A - H' selected>A - H</option>";
  • echo "<option value ='I - Q'>I - Q</option>";
  • echo "<option value ='R - Z'>R - Z</option>";
  • echo "</select>  &nbsp";
  • echo "<input type='submit' name='submit' value='Proceed'>";
  • if(isset($_POST["submit"]))
  • {
  • $an = $_POST["an"];
  • $submit = $_POST["submit"];
  • if($submit=="proceed"
  • {
  • $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());
  • if(isset($_POST['an']))
  • {
  • $an=$_POST["an"];
  • if($an == "A - G"
  • {
  • $sql = "SELECT * from association Where AssociationName BETWEEN 'A%' AND 'H%' ORDER BY AssociationName";
  • $result = mysql_query($sql);
  • $row = mysql_fetch_array($result);
  • echo "<p>";
  • echo "ID              : <input type='text' name='id1' value='$row[ID]' size='40'><br>";
  • echo "Association Name                : <input type='text' name='an1' value='$row[AssociationName]' size='40'><br>";
  • echo "<input type='submit' name='submit' value='update'>";
  • }
  • else if($an == "H - Q"
  • {
  • $sql = "SELECT * from association Where AssociationName BETWEEN 'H%' AND 'R%' ORDER BY AssociationName";
  • $result = mysql_query($sql);
  • $row = mysql_fetch_array($result);
  • echo "<p>";
  • echo "ID              : <input type='text' name='id2' value='$row[ID]' size='40'><br>";
  • echo "Association Name                : <input type='text' name='an2' value='$row[AssociationName]' size='40'><br>";
  • echo "<input type='submit' name='submit' value='update'>";
  • }
  • else if($an == "R - Z"
  • {
  • $sql = "SELECT * from association Where AssociationName BETWEEN 'R%' AND 'Z%' OR AssociationName LIKE 'Z%' ORDER BY AssociationName";
  • $result = mysql_query($sql);
  • $row = mysql_fetch_array($result);
  • echo "<p>";
  • echo "ID              : <input type='text' name='id3' value='$row[ID]' size='40'><br>";
  • echo "Association Name                : <input type='text' name='an3' value='$row[AssociationName]' size='40'><br>";
  • echo "<input type='submit' name='submit' value='update'>";
  • }
  • }
  • }
  • if($submit=="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'";
  • $result = mysql_query($sql);
  • if (mysql_num_rows($result2) < 1)
  • {
  • echo "<hr><h2>Record Updated</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=AssociationAdd.php'>
  • <CENTER><p> </p><p>
  • <tr>
  • <td align='center'><h12>please wait...</h12></td>
  • </tr>
  • </table><p> </p><p> </p></CENTER></BODY></HTML>";
  • }
  • }
  • }
  • ?>
  • </form>
  • <p align="center"> </p>
  • <p align="center"> </p>
  • <p align="center"> </p>
  • <p align="center"> </p>
  • <p align="center"> </p>
  • </div>
  • </body>
  • </html>
回复

使用道具 举报

 楼主| 发表于 17-10-2009 07:17 AM | 显示全部楼层
<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='4' face='Arial Rounded MT Bold'><font color='#FFFFFF'><span lang='en-us'>lease select a group : </font></span>";

    echo"<select name='an'>";
    echo "<option>---Please Select---</option>";
    echo "<option value='A - H' selected>A - H</option>";
    echo "<option value ='I - Q'>I - Q</option>";
    echo "<option value ='R - Z'>R - Z</option>";   
    echo "</select>  &nbsp";
    echo "<input type='submit' name='submit' value='Proceed'>";

    if(isset($_POST["submit"]))
    {
        $an = $_POST["an"];
        $submit = $_POST["submit"];
        if($submit=="proceed"
        {  
             $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());
               
             if(isset($_POST['an']))
             {
                 $an=$_POST["an"];
                 if($an == "A - G"
                 {
                    $sql = "SELECT * from association Where AssociationName BETWEEN 'A%' AND 'H%' ORDER BY AssociationName";
                    $result = mysql_query($sql);
                    $row = mysql_fetch_array($result);
                    echo "<p>";
                    echo "ID          : <input type='text' name='id1' value='$row[ID]' size='40'><br>";
                    echo "Association Name            : <input type='text' name='an1' value='$row[AssociationName]' size='40'><br>";
                    echo "<input type='submit' name='submit' value='update'>";

                }

                else if($an == "H - Q"
                 {
                    $sql = "SELECT * from association Where AssociationName BETWEEN 'H%' AND 'R%' ORDER BY AssociationName";
                    $result = mysql_query($sql);
                    $row = mysql_fetch_array($result);
                    echo "<p>";
                    echo "ID          : <input type='text' name='id2' value='$row[ID]' size='40'><br>";
                    echo "Association Name            : <input type='text' name='an2' value='$row[AssociationName]' size='40'><br>";
                    echo "<input type='submit' name='submit' value='update'>";

                }
               
                 else if($an == "R - Z"
                    {
                    $sql = "SELECT * from association Where AssociationName BETWEEN 'R%' AND 'Z%' OR AssociationName LIKE 'Z%' ORDER BY AssociationName";
                    $result = mysql_query($sql);
                    $row = mysql_fetch_array($result);
                    echo "<p>";
                    echo "ID          : <input type='text' name='id3' value='$row[ID]' size='40'><br>";
                    echo "Association Name            : <input type='text' name='an3' value='$row[AssociationName]' size='40'><br>";
                    echo "<input type='submit' name='submit' value='update'>";
                }
             }
        }
               
        if($submit=="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'";
                $result = mysql_query($sql);
               
                if (mysql_num_rows($result2) < 1)
                {
                    echo "<hr><h2>Record Updated</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=AssociationAdd.php'>
                                 <CENTER><p> </p><p>
                                        <tr>
                                        <td align='center'><h12>please wait...</h12></td>
                                        </tr>
                                </table><p> </p><p> </p></CENTER></BODY></HTML>";
            }
         }
    }
?>
</form>

<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
</div>
</body>
</html>

不知道你们觉得哪种会比较容易看。
回复

使用道具 举报

发表于 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 | 显示全部楼层
原帖由 NgSzeyin2005 于 4-10-2009 08:06 PM 发表
还有,要怎样才能让网站里的东西不会跑位呢?我只要放大或放小(Scroll Up/Down),那些buttons和字就会跑位了。

网站scrolling 的问题是因为 html 布局。
有些是因为 div, 有些是width % 或 fixed width, 有些是 css。
很难告诉你原因出在哪里,要把整个网站的 html code 看过才知道。

现在我query不到database所有的的东西,只能query到一个而已.
我的database只有Index和Name,我的Name都是不同的,可是Index有些是相同的

database 的结构很重要,必须使用至少一个 unique id 来 identify 相关的 record。如果这点做不到,以后的maintenance 会比较麻烦。
刚刚稍微看了一下你的代码,请问你在那里使用了 looping ? 你说的只能 query 到一个记录是因为没有使用 looping 吗?
回复

使用道具 举报

Follow Us
 楼主| 发表于 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都没有空...
回复

使用道具 举报


ADVERTISEMENT

 楼主| 发表于 19-10-2009 10:53 PM | 显示全部楼层
原帖由 Legend 于 19-10-2009 07:38 PM 发表
echo update的sql出来看, 看下对不对...看$id或$pk都没有空...

已经解决了,谢谢大家。。。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 5-12-2025 09:08 PM , Processed in 0.106230 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表