-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb_ch.php
More file actions
54 lines (50 loc) · 1.8 KB
/
db_ch.php
File metadata and controls
54 lines (50 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>建立数据库表</title>
</head>
<body>
<?php
//connect to MySQL
$db=mysqli_connect('localhost','root','wzj196310') or die ('Unable to connect.Check your connection parameters.');
//create the main database if it doesn't already exist
$sql='create database if not exists moviesite';
mysqli_query($db,$sql) or die(mysqli_error($db));
//make sure our recently created database is the active one
mysqli_select_db($db,'moviesite') or die(mysqli_error($db));
//create the movie table
$sql='create table movie(
movie_id integer unsigned not null auto_increment,
movie_name varchar(255) not null,
movie_type tinyint not null default 0,
movie_year smallint unsigned not null default 0,
movie_leadactor integer unsigned not null default 0,
movie_director integer unsigned not null default 0,
primary key(movie_id),
key movie_type(movie_type,movie_year)
)
engine=myisam';
//mysqli_query($db,$sql) or die (mysqli_error($db));
//create the movietype table
$sql='create table movietype(
movietype_id tinyint unsigned not null auto_increment,
movietype_label varchar(100) not null,
primary key(movietype_id)
)
engine=myisam';
//mysqli_query($db,$sql) or die (mysqli_error($db));
//create the people table
$sql='create table people(
people_id integer unsigned not null auto_increment,
people_fullname varchar(255) not null,
people_isactor tinyint(1) unsigned not null default 0,
people_isdirector tinyint(1) unsigned not null default 0,
primary key(people_id)
)
engine=myisam';
//mysqli_query($db,$sql) or die (mysqli_error($db));
echo 'Movie database successfully created!';
?>
</body>
</html>