-
Notifications
You must be signed in to change notification settings - Fork 5
/
creattable1.php
91 lines (75 loc) · 1.47 KB
/
creattable1.php
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
$dbname = "hostels";
$username = "root";
$password = "";
$servername ="localhost";
$conn = new mysqli($servername,$username,$password,$dbname);
if( $conn->connect_error){
die("connection failier". $conn->connect_error);
}
$sql = "
create table Owner_details(
Owner_name varchar(20),
Phone_number varchar(10),
Email_ID varchar(30),
primary key(Phone_number)
);
";
$sql .= "
create table area(
pincode varchar(6),
No_of_pgs int,
city varchar(20),
no_of_hostels int,
locality varchar(20),
primary key(pincode)
);
";
$sql .= "
create table Hostel(
ID int not null auto_increment primary key,
H_name varchar(20),
Pincode char(6),
Type varchar(10),
Hostel boolean,
Curfew time,
Phone_number varchar(10),
Total_no_of_rooms int,
Capacity int,
foreign key(Pincode) references Area(Pincode),
foreign key(Phone_number) references Owner_details(Phone_number)
);
";
$sql .= "
create table mess(
no_of_meals int,
Mess_fees int,
Mess_capacity int,
Veg boolean,
Schedule blob,
ID int,
foreign key(ID) references Hostel(ID)
);";
$sql .= "
create table Room_types(
Attached_Bathroom Boolean,
AC boolean,
Room_capacity int,
Fees int,
Wifi boolean,
No_of_rooms int,
ID int,
foreign key(ID) references Hostel(ID)
);";
// $result = mysql_query($sql1,$sql2,$sql3);
if($conn->multi_query($sql)){
echo "Table created";
}
else{
echo "error creating table" . $conn->error;
}
// $conn->query($sql3);
// $conn->query($sql4);
// $conn->query($sql5);
$conn->close();
?>