首页 > 数据库 > MySQL > 正文

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

2024-07-24 12:56:04
字体:
来源:转载
供稿:网友

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


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表