<title>Insert</title>
</">

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

80酷酷网    80kuku.com

  mysql|应用实例

一,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> </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)



分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: