-
Notifications
You must be signed in to change notification settings - Fork 0
/
firsttime.php
59 lines (44 loc) · 2.03 KB
/
firsttime.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
<?php
//Setting up connection
$servername="localhost";
$username ="root";
$password = "";
$conn= mysqli_connect($servername,$username,$password);
if(!$conn){
die("Sorry we failed to connect:". mysqli_connect_error());
}else{
echo "Conection was esatablished succesfully. <br>";
}
//Creating database bank
$sql= "CREATE DATABASE Bank";
$result = mysqli_query($conn,$sql);
if(!$result){
echo "Sorry we failed to create database. <br>";
}else{
echo "DATABASE Created Successfully.<br>";
}
//Creating table customers
$sql = "CREATE TABLE `bank`.`customers` ( `Cust_ID` INT NOT NULL AUTO_INCREMENT , `Name` VARCHAR(11) NOT NULL , `Email` VARCHAR(20) NOT NULL , `Amount` FLOAT(30) NOT NULL , PRIMARY KEY (`Cust_ID`)) ";
$result = mysqli_query($conn,$sql);
if(!$result){
echo "Sorry we failed to create table.<br>";
}else{
echo "Customer Table Created Successfully.<br>";
}
//Adding 10 dummey data into table customers
$sql ="INSERT INTO `bank`.`customers` (`Cust_ID`, `Name`, `Email`, `Amount`) VALUES ('1', 'harish', 'harish@yahoo.com', '3000.00'), ('2', 'shivam', 'shivam@orkut.com', '10000.00'), ('3', 'niladri', 'niladri@outlook.com', '5000.00'), ('4', 'raj', 'raj@gmail.com', '15000.00'), ('5', 'parkash', 'parkash@rediff.com', '20000.00'), ('6', 'kunal', 'kunal@xyz.com', '3500.00'), ('7', 'rahul', 'rahul@abc.com', '12000.00'), ('8', 'aryan', 'aryan@123.com', '30000.00'), ('9', 'chandan', 'chandan@gmail.com', '23000.00'), ('10', 'vikas', 'vikas@def.com', '40000.00')";
$result = mysqli_query($conn,$sql);
if(!$result){
echo "Sorry we failed to add entries to table. <br>";
}else{
echo "Entries added to table Successfully.<br>";
}
//Creating transaction table customers
$sql = "CREATE TABLE `bank`.`transaction` ( `Tran_ID` INT NOT NULL AUTO_INCREMENT , `From` VARCHAR(11) NOT NULL , `To` VARCHAR(11) NOT NULL , `Amount` DECIMAL NOT NULL , PRIMARY KEY (`Tran_ID`))";
$result = mysqli_query($conn,$sql);
if(!$result){
echo "Sorry we failed to create table.<br>";
}else{
echo "Transaction Table Created Successfully.<br>";
}
?>