Run the code below.
Copy codeThe Code is as follows:
<? Php
// Date_default_timezone_set ("Asia/Shanghai ");
/*
Function create_siteinfo
DONE: website information table
Author: www.5dkx.com
DATE: 2010-3-30
Table Structure:
Title website name
Keyword website keywords
Description website description
*/
Function create_siteinfo ()
{
Global $ conn;
$ SQL = "create table siteinfo (
Title varchar (100) not null,
Key word varchar (200) not null,
Description varchar (200) not null
)";
$ Dropsql = "drop table if exists siteinfo ";
Mysql_query ($ dropsql, $ conn) or die ("failed to delete table siteinfo! ");
Mysql_query ($ SQL, $ conn) or die ("failed to create table siteinfo! ");
}
/*
Function: create_article ()
DONE: SQL statement used to create an article table in mysql
Author: www.5dkx.com
Table Structure:
Id Article ID
Cid category ID
Abstract
Title article title
Posttime release time
Author of aurhor
Comefrom Article Source
Comeurl source URL
Content
Keyword keywords
Rank document level
Views
*/
Function create_article ()
{
Global $ conn, $ table_article;
$ SQL = "create table $ table_article (
Id int (11) auto_increment not null,
Cid int (5) not null,
Abstract varchar (300) not null,
Title varchar (50) not null,
Posttime datetime not null,
Author varchar (30) not null,
Comefrom varchar (50) not null,
Comeurl varchar (50) not null,
Content TEXT not null,
Keyword varchar (20) not null,
Rank int (2) not null,
Views int (5) not null,
Primary key (id)
)";
$ Dropsql = "drop table if exists $ table_article ";
Mysql_query ($ dropsql, $ conn) or die ("An error occurred while deleting the database! ");
Mysql_query ($ SQL, $ conn) or die ("failed to create database! ");
}
/*
Function: create_member ()
DONE: SQL statement for creating a member table in mysql
Author: www.5dkx.com
Uid member ID
U_name member name
U_passwd Password
Rank membership level
*/
Function create_member ()
{
Global $ conn, $ table_member;
$ SQL = "create table $ table_member (
Uid int (5) auto_increment not null,
U_name varchar (20) not null UNIQUE,
U_passwd varchar (100) not null,
Rank int (2) not null,
Primary key (uid)
)";
$ Dropsql = "drop table if exists $ table_member ";
Mysql_query ($ dropsql, $ conn) or die ("An error occurred while deleting the database! ");
Mysql_query ($ SQL, $ conn) or die ("failed to create database! ");
}
/*
Function: create_class
DONE: SQL statement used to create a category
Author: www.5dkx.com
Table Structure:
Cid category ID
Cname Class Name
*/
Function create_class ()
{
Global $ conn, $ table_class;
$ SQL = "create table $ table_class (
Cid int (5) auto_increment not null,
Cname varchar (50) not null UNIQUE,
Primary key (cid)
)";
$ Dropsql = "drop table if exists $ table_class ";
Mysql_query ($ dropsql, $ conn) or die ("delete". $ table_class. "failed! ");
Mysql_query ($ SQL, $ conn) or die ("CREATE TABLE". $ table_class. "failed ");
}
/*
Function: create_guest
DONE: SQL statement used to create a message board
Author: www.5dkx.com
Table Structure:
Gid Message ID
G_name message Username
G_site user's personal homepage
G_mail user email
G_cid location (which article or message board)
*/
Function create_guest ()
{
Global $ conn, $ table_guest;
$ SQL = "create table $ table_guest (
Gid int (11) auto_increment not null,
G_name varchar (50) not null,
G_site varchar (50) not null,
G_mail varchar (50) not null,
G_cid int (5) not null,
Primary key (gid)
)";
$ Dropsql = "drop table if exists $ table_guest ";
Mysql_query ($ dropsql, $ conn) or die ("Delete table". $ table_guest. "failed ");
Mysql_query ($ SQL, $ conn) or die ("CREATE TABLE". $ table_guest. "failed ");
}
Function create_ SQL ()
{
Global $ table_article, $ table_member, $ table_class, $ table_guest, $ conn;
Echo "create siteinfo table \ r ...... ";
Create_siteinfo ();
Echo "complete <br> ";
Echo "CREATE". $ table_article. "Table \ r ...... ";
Create_article ();
Echo "complete <br> ";
Echo "CREATE". $ table_member. "Table \ r ...... ";
Create_member ();
Echo "complete <br> ";
Echo "CREATE". $ table_class. "Table \ r ...... ";
Create_class ();
Echo "complete <br> ";
Echo "CREATE". $ table_guest. "Table \ r ...... ";
Create_guest ();
Echo "complete <br> ";
Mysql_close ($ conn );
}
?>