-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCT.php
62 lines (55 loc) · 2.4 KB
/
CT.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
<?php
$server_name = "localhost";
$user_name = "root";
$password = "";
$database_name = "clients_db";
$database_created = FALSE;
$connection = mysqli_connect($server_name, $user_name, $password);
if($connection){
$query = "CREATE DATABASE $database_name";
$result = mysqli_query($connection, $query);
if($result) {
echo "Database created!<br>";
$database_created = TRUE;
} else {
echo "ERROR creating DB : " . mysqli_error($connection);
}
mysqli_close($connection);
} else {
echo "ERROR: Could not connect : " . mysqli_connect_error();
}
if($database_created){
$table_name = "clients_table";
$connection = mysqli_connect($server_name, $user_name, $password, $database_name);
if($connection){
$query = "CREATE TABLE $table_name(
client_number INT NOT NULL PRIMARY KEY,
client_name VARCHAR(32) NOT NULL,
client_email VARCHAR(32) NOT NULL,
client_password VARCHAR(255) NOT NULL,
client_phone_number VARCHAR(10) NOT NULL,
client_business_name VARCHAR(32) NOT NULL,
client_db_name VARCHAR(16) NOT NULL,
client_pincode INT NOT NULL,
client_address VARCHAR(32) NOT NULL,
client_customer_count INT NOT NULL,
client_date_of_registration DATE NOT NULL,
credit_percentage DECIMAL(5, 2) NOT NULL,
debit_percentage DECIMAL(5, 2) NOT NULL,
loyalty_coin_value DECIMAL(5, 2) NOT NULL,
total_transaction_amount INT NOT NULL,
total_redemption_amount INT NOT NULL,
account_status VARCHAR(10) NOT NULL
);";
$result = mysqli_query($connection, $query);
if($result) {
echo "Table created!<br>";
} else {
echo "ERROR creating Table : " . mysqli_error($connection);
}
mysqli_close($connection);
} else {
echo "ERROR: Could not connect : ".mysqli_connect_error();
}
}
?>