首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > PHP >

关于服务器提交和响应的有关问题

2012-02-16 
关于服务器提交和响应的问题我这里有一个例子我是新手初学来着我每次第一次提交数据库表会更新表格里面则

关于服务器提交和响应的问题
我这里有一个例子 我是新手 初学来着
我每次第一次提交数据库表会更新 表格里面则不会 需要第二次提交表格里面才会出现数据库的最新数据
我应该怎么解决呢?

PHP code
<html><head>  <title>connect db</title></head><body><form action="/aaa.php" method="post">    <table border=1>    <?php    $link=mysql_connect("localhost","root","");    mysql_select_db("s");    $result=mysql_query("select Name from stud");    for($a=0;$a<3;$a++)    {        echo "<tr>";        for($b=0;$b<3;$b++)        {            $c="LL".$a.$b;            if($l=mysql_fetch_array($result,MYSQL_NUM))            {                $$c=$l[0];                echo "<td><input type=\"text\" name=\"lll".$a.$b."\" value=".$$c."></td>";            }            else            {                $$c="";                echo "<td><input type=\"text\" name=\"lll".$a.$b."\" value=".$$c."></td>";            }        }        echo "</tr>";    }    ?></table><input type="text" name="Name"><input type="text" name="Age"><input type="submit" name="submit1" value="tj"><?php if($_POST["Name"]!="" and $_POST["Age"]!=""){    mysql_query("insert into stud select last_insert_id(),'".$_POST["Name"]."',".(int)$_POST["Age"]);    for($a=0;$a<3;$a++)    {        for($b=0;$b<3;$b++)        {            $c="LL".$a.$b;            if($l=mysql_fetch_array($result,MYSQL_NUM))            {                $$c=$l[0];            }            else            {                $$c="";            }        }    }}else{    print "格式不正确";}?></form></body></html> 


[解决办法]
你把两段php的顺序交换以下即可。

热点排行