日期:2014-05-17 浏览次数:20453 次
<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>