-
Notifications
You must be signed in to change notification settings - Fork 0
/
search-customer.php
66 lines (64 loc) · 2.56 KB
/
search-customer.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
<?php
require_once('connection.php');
require_once('middleware.php');
if(isset($_POST['name'])){
$search_name = strtolower(cleanInput($_POST['name']));
$sql = "SELECT * FROM customers";
$result = $conn->query($sql);
$customers = array();
while($row = $result->fetch_assoc()){
$customer_name = strtolower($row['name']);
$k = 0;
$control = 1;
$s_len = strlen($search_name);
$c_len = strlen($customer_name);
if($s_len > $c_len)
$len = $c_len;
else $len = $s_len;
for($i=0; $i<$len; $i++){
if($search_name[$i] != $customer_name[$k++]){
$control = 0;
break;
}
}
if($control){
array_push($customers, $row);
}
}
}
?>
<?php
if(sizeof($customers) == 0){
?>
<div class="danger"><i class="fas fa-exclamation-circle"></i> No customers found with the given name</div>
<?php
}
foreach($customers as $row){
?>
<div class="customer-card border card flex-row">
<div class="flex-col pr-20px">
<label class="label">Name</label>
<label class="label">A/C</label>
<label class="label">IFSC code</label>
<label class="label">E-mail</label>
<label class="label">Contact</label>
<label class="label">Location</label>
<label class="label">State</label>
<label class="label mt-10px">Balance</label>
</div>
<div class="flex-col">
<label ><?php echo $row['name']; ?></label>
<label ><span class="highlight-blue"><?php echo $row['account_num']; ?></span></label>
<label ><?php echo $row['IFSC_Code']; ?></label>
<label><?php echo $row['email']; ?></label>
<label><?php echo $row['contact_num']; ?></label>
<label><?php echo $row['location']; ?></label>
<label><?php echo $row['State']; ?></label>
<label class="mt-10px"><span class="highlight-green"><?php echo $row['current_balance']; ?> <i class="fas fa-rupee-sign"></i></span></label>
</div>
<i class="fas fa-user user-icon"></i>
<button onclick="location.href='transaction.php?c_id=<?php echo $row['customer_id']; ?>'" class="pay"><i class="fas fa-share mr-5px"></i>Pay</button>
</div>
<?php
}
?>