- A+
1、使用DDL语句创建数据库、创建表。
mysql> show databases;
+--------------------+
| Database
+--------------------+
| information_schema |
| class_info
| houdunwang
| mysql
| test
+--------------------+
5 rows in set (0.00 sec)
mysql> create database student_info;
Query OK, 1 row affected (0.01 sec)
mysql>
Query OK, 0 rows affected (0.06 sec)
2、向student_info 表中插入数据:
insert into student_info values("000004","david.sun","nv","26");
3、查看当前student_info表内的数据:
mysql> select * from student_info;
+----+-------------+------+------+
| id | name
+----+-------------+------+------+
|
|
|
|
+----+-------------+------+------+
4 rows in set (0.00 sec)
4、编写php程序
//连接数据库
mysql_connect("localhost","root","123456",);
//选择数据库
mysql_select_db("student_info");
//查询student_info表内的数据
$output=mysql_query("select * from student_info");
//将student_info表数据输出一条
//mysql_fetch_assoc($output);
while($arr=mysql_fetch_assoc($output)){
}
?>
<table width=300 border=1 align="center">
<caption><h2>学生信息表</h2></caption>
<?php
<?php
?>
</table>