-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
57 lines (53 loc) · 2.09 KB
/
search.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
<!--Creating a search button-->
<!--==Author (c)frankline_bwire==-->
<h1 style="font-weight:bolder">iSearch</h1>
<h4 style="width:40%">This database application lets you search for patient information, available in the patient database (searchdb.sql) from different tables and gives accurate output.</h4>
<?php
include 'db.php';
?>
<form method="post" action="search.php">
<input type=text name="search" placeholder="Search">
<input type="submit" name="searchbt">
</form>
<!--Search Query-->
<?php
$search="";
if(isset($_POST["searchbt"])){
$search=mysqli_real_escape_string($connect,$_POST["search"]);
//get data from multiple tables (join)
$sql="Select * from patients , emergency_contacts where patients.patient_id = '$search' and emergency_contacts.patient_id = '$search' limit 1";
$query=mysqli_query($connect,$sql) or die ("Unable to get result". mysqli_error($connect));
$result=mysqli_fetch_assoc($query);
}
?>
<!--OUTPUT-->
<?php
if($result == true){
?>
<form>
First Name: <input type="text" value="<?php echo $result["first_name"]?>" readonly>
<br>
Last Name: <input type="text" value="<?php echo $result["last_name"]?>" readonly>
<br>
Email: <input type="text" value="<?php echo $result["patient_email"]?>" readonly>
<br>
City: <input type="text" value="<?php echo $result["patient_city"]?>" readonly>
<br>
Address: <input type="text" value="<?php echo $result["patient_address"]?>" readonly>
<br>
Gender: <input type="text" value="<?php echo $result["patient_gender"]?>" readonly>
<br>
Kin: <input type="text" value="<?php echo $result["kin_name"]?>" readonly>
<br>
Relationship: <input type="text" value="<?php echo $result["relationship"]?>" readonly>
<br>
Kin Gender: <input type="text" value="<?php echo $result["kin_gender"]?>" readonly>
</form>
<?php
}
if(!$result){
echo "No results found for <strong style='color:red'>$search</strong> record, or the record does not exist.";
};
echo "done";
?>
<p><a href="register.php">Register</a> new patient</p>