LOADING STUFF...

PHP5与MySQL数据库操作常用代码 收集

技术教程4小时前更新 北陌
22 0 0
1 建立数据库表:

create database club;

create table member(

id int(11) not null auto_increment,

no varchar(5) not null,

name varchar(10) not null,

age int(2) not null,

level varchar(10) not null,

sex tinyint(1) not null,

date datetime not null,

primary key(id)

)engine=MyISAM default charset=GB2312;

insert into member(id,no,name,age,level,sex,date)values

(1,A001,wanxia,30,hj,1,2008-04-02 00:00:00),

(2,C022,liyan,29,zs,1,2007-05-31 00:00:00),

(3,A006,zhangyan,36,hj,1,2007-06-20 00:00:00),

(4,B052,luanying,42,bj,1,2007-02-12 00:00:00),

(5,A007,duxiang,26,hj,2,2008-03-26 00:00:00),

(6,C060,liuyu,38,zs,1,2008-10-16 00:00:00);

PHP5与MySQL数据库操作常用代码 收集2 读取数据

2.1 建立01.php

代码

会员列表

$link=mysql_connect(“localhost”,”root”,”123″); //连接mysql服务器

$db=mysql_select_db(“club”); //选择数据库

mysql_query(“set names utf8”,$link); //设定编码方式

$sql=”Select * from member”;

$result=mysql_query($sql,$link); //执行select查询

$num=mysql_num_rows($result); //获取记录查询

?

© 版权声明

相关文章

暂无评论

暂无评论...