-
Notifications
You must be signed in to change notification settings - Fork 1
/
patient.php
49 lines (42 loc) · 1.27 KB
/
patient.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
<?php
require_once 'dbcon/connection.php';
function genPatientId(){
$sufix = array ('A','B','C','D','E','F','G','H','I','J','K');
return "P" . date("Yms"). $sufix[rand(0, 10)] . $sufix[rand(2, 8)];
}
function regPatient($pid, $surname, $oname, $gender, $passport){
$con = connect();
$con->query("insert into patient values('$pid', '$surname', '$oname', '$gender', '$passport')");
$rows = $con->affected_rows;
$con->close();
return $rows;
}
function getPatients(){
$con = connect();
$table = $con->query("select * from patient");
$con->close();
return $table;
}
function getPatient($pid)
{
$con = connect();
$table = $con->query("select * from patient where pid = '$pid'");
$record = $table->fetch_array();
$table->close();
$con->close();
return $record;
}
function updatePatient($pid, $surname, $othername, $gender){
$con = connect();
$con->query("update patient set sname='$surname', oname='$othername', gender='$gender' where pid='$pid'");
$row=$con->affected_rows;
$con->close;
return $row;
}
function deletePatient($pid) {
$con = connect();
$con->query("delete from patient where pid='$pid'");
$row=$con->affected_rows;
$con->close;
return $row;
}