Php应用实例--新增资料录到MySQL资料表

发表于:2007-06-21来源:作者:点击数: 标签:
一,Insert.htm源码: html head meta http-equiv="Content-Type" content="text/html; charset=gb2312" titleInsert/title /head body pScore资料表--新增资料录 /p phr noshade/p form name="form1" method="post" action="insert.htm" table width="200"

   
  

一,Insert.htm源码:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Insert</title>
</head>

<body>
<p>Score资料表--新增资料录
</p>
<p><hr noshade></p>
              <form name="form1" method="post" action="insert.htm">
                <table width="200" border="0" align="center">
                  <tr>
                    <td>Number</td>
                    <td><input type="text" name="Number"></td>
                  </tr>
                  <tr>
                    <td>Name</td>
                    <td><input type="text" name="Name"></td>
                  </tr>
                  <tr>
                    <td>Chinese</td>
                    <td><input type="text" name="Chinese"></td>
                  </tr>
                  <tr>
                    <td>English</td>
                    <td><input type="text" name="English"></td>
                  </tr>
                  <tr>
                    <td>Math</td>
                    <td><input type="text" name="Math"></td>
                  </tr>
                  <tr>
                    <td><input type="submit" name="Submit" value="提交"></td>
                    <td>&nbsp;</td>
                  </tr>
                </table>
              </form>
     <hr noshade>
   
</body>
</html>

二,Insert.php源码:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>insert</title>
</head>

<body>
<?php
mysql_connect("ftp","root","");
mysql_select_db("test");
$sql="insert into score (Number,Name,Chinese,English,Math) values ($Number,'$Name',$Chinese,$English,$Math)";
mysql_query($sql);
?> 新增一笔资料成功,<a href="insert.htm">请反回</a>!
</body>
</html>

所用到的SQL语句:insert into score (Number,Name,Chinese,English,Math) values ($Number,'$Name',$Chinese,$English,$Math)

原文转自:http://www.ltesting.net