-
Notifications
You must be signed in to change notification settings - Fork 1
/
admin_service.php
157 lines (122 loc) Β· 5.09 KB
/
admin_service.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
function get_db_connection(){
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "doctorpatientportal";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Ops! Something wrong has happened!" . mysqli_connect_error());
}
return $conn;
}
?>
<?php
//Create method for the doctor
function add_doctor($first_name, $last_name, $user_name, $password, $gender, $email, $specialty, $address, $contact_no){
$query = "INSERT INTO doctors(first_name, last_name, user_name, password, gender,
email, specialty, address, contact_no) VALUES('$first_name', '$last_name', '$user_name', '$password','$gender', '$email', '$specialty', '$address', '$contact_no')";
return mysqli_query(get_db_connection(), $query);
}
/*function edit_doctor($id, $name){
$query = "UPDATE doctors SET name='$name' WHERE id=$id";
return mysqli_query(get_db_connection(), $query);
}*/
function remove_doctor($id){
$query = "DELETE FROM doctors WHERE id=$id";
return mysqli_query(get_db_connection(), $query);
}
function get_all_doctor(){
$query = "SELECT * FROM doctors";
return mysqli_query(get_db_connection(), $query);
}
function get_doctor_by_id($id){
$query = "SELECT * FROM doctors WHERE id=$id";
return mysqli_query(get_db_connection(), $query);
}
function get_doctor_by_specialty($specialty){
$query = "SELECT * FROM doctors WHERE specialty like '%$specialty%'";
return mysqli_query(get_db_connection(), $query);
}
//Search doctor by using firstname,lastname,email,specialty,or contact no
function search_doctor($first_name, $last_name, $email, $specialty, $contact_no){
$query="SELECT * FROM doctors where first_name like '%$first_name%'
or last_name like '%$last_name%' or email like '%$email%'
or specialty like '%$specialty%' or contact_no like '%$contact_no%' ";
return mysqli_query(get_db_connection(), $query);
}
//Create method for the donar
function add_donar($organ_id, $name, $gender, $email, $blood_group, $address, $contact_no){
$query = "INSERT INTO organ_donar(organ_id, name, gender,
email, blood_group, address, contact_no) VALUES('$organ_id', '$name',
'$gender', '$email', '$blood_group', '$address', '$contact_no')";
return mysqli_query(get_db_connection(), $query);
}
function add_new_donar($organ_id, $name, $gender, $email, $blood_group, $address, $contact_no,$organname){
$query = "INSERT INTO organ_donar(organ_id, name, gender,
email, blood_group, address, contact_no, organname) VALUES('$organ_id', '$name',
'$gender', '$email', '$blood_group', '$address', '$contact_no', '$organname')";
return mysqli_query(get_db_connection(), $query);
}
function get_all_donar(){
$query = "SELECT * FROM organ_donar";
return mysqli_query(get_db_connection(), $query);
}
function get_donar_by_blood_group($blood_group){
$query = "SELECT * FROM organ_donar WHERE blood_group like '%$blood_group%'";
return mysqli_query(get_db_connection(), $query);
}
function get_donar_by_organ_name($organname){
$query = "SELECT * FROM organ_donar WHERE organname like '%$organname%'";
return mysqli_query(get_db_connection(), $query);
}
//Search donar
function search_donar($name, $blood_group, $organname, $contact_no){
$query="SELECT * FROM organ_donar where name like '%$name%'
or blood_group like '%$blood_group%' or organname like '%$organname%' or
contact_no like '%$contact_no%' ";
return mysqli_query(get_db_connection(), $query);
}
//create method for admin
function get_admin_profile($username){
$query = "SELECT * FROM admin WHERE user_name like '$username'";
return mysqli_query(get_db_connection(), $query);
}
function edit_admin_password($username, $password){
$query = "UPDATE admin SET password ='$password' WHERE user_name= '$username'";
return mysqli_query(get_db_connection(), $query);
}
//get all organ methdo
function get_all_organ(){
$query="SELECT * FROM organ";
return mysqli_query(get_db_connection(), $query);
}
//method for get all organ by id
function get_all_organ_by_id($id){
$query="SELECT * FROM organ where id=$id";
return mysqli_query(get_db_connection(), $query);
}
//method for count total patient
function get_total_patient(){
$query="SELECT * FROM patients";
return mysqli_query(get_db_connection(),$query);
}
//method for count total doctor
function get_total_doctor(){
$query="SELECT * FROM doctors";
return mysqli_query(get_db_connection(),$query);
}
//method for count total donar
function get_total_donor(){
$query="SELECT * FROM organ_donar";
return mysqli_query(get_db_connection(),$query);
}
//add appointment schedule
function add_schedule($doctor_id,$appoint_date,$appoint_time,$status){
$query="INSERT INTO appointment (doctor_id, appoint_date, appoint_time, status)
VALUES ('$doctor_id', '$appoint_date', '$appoint_time', '$status')";
return mysqli_query(get_db_connection(),$query);
}
?>